dynamic xhtml through perl/cgi

Ken Elliott's picture

They have: 358 posts

Joined: Jun 1999

Hola,
I am creating a CMS system for a website I am building and I checked the output on the W3C validator and my html sucks..heh. So I'm bringing myself abreast to current W3C standards and want to start coding my stuff in XHTML as suggested by the W3C. I've read alot of posts on the subject, and though I feel that the W3C standards are not fully supported now, they will be in the future, and conforming to them now is important.

However such a change invokes a flurry of questions, and I'm burning for answers.

1. I noticed that pretty much every attribute attached to almost every tag causes an error. Are all of these supposed to be supplied through CSS?

2. I do most of my work with Perl, how do I use xhtml in conjunction with perl? Would it be like Content-type:text/xhtml\n\n

I'll start with those for now. Any help I can get is appeciated.

webG

Pimpin like a pimp with an electrofied pimpin machine!

KarenArt's picture

She has: 354 posts

Joined: May 2001

Hola Ken!

Well I've only worked with xhtml a couple of times, but the one thing I learned is xhtml is no harder than regular html as long as you remember to close all your tags and keep things in lowercase.

So..... something like becomes and becomes
Just remember to close all your tags (including the meta tags) and you'll be fine. Also remember to use lowercase. is wrong. is right.

I'm not sure about the content type. I thought is would still be text/html. Now I'm all confused.
You do want the right doctype though...
<?xml version="1.0" encoding="utf-8"?>

Check out the page at http://www.w3.org/International/articles/serving-xhtml/

Hopefully someone smarter than me will come along (you shouldn't have to wait too long for that) and answer your questions.

gotta finish redesigning my sites so I can show them again.

The purpose of education is... to get more jokes!

He has: 1,758 posts

Joined: Jul 2002

Yes... you still need to output as text/html

I believe technically it should be something like text/xml but the older browsers don't fully support xml (which is what xhtml is) and won't be able to correctly parse the document or something like that.

Try to avoid inline styles in your documents (ie ) and put anything thats related to position, colour, style etc in the css. Lots of html attributes such as align, bgcolor and things like that have been depreciated in xhtml hence the errors.

Andy

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

http://www.hixie.ch/advocacy/xhtml

application/xhtml+xml is the correct mime-type, which only Mozilla understands, I think. If you do use this correct mime-type, your code will have to be strictly valid.

text/html works for all other browsers.

You can use a bit of server-side code to detect if the HTTP request is from an-XHTML compatible client (i.e. Mozilla), and then serve up a slightly altered version, and send tag soup for others. http://www.xml.com/pub/a/2003/03/19/dive-into-xml.html

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.