Forum Moderators: open
application/xhtml+xml (not recommended since IE doesn't support it).
XHTML is not much different from what you have it is just a good excercise in preparing for XML - mainly making sure all elements are closed like <br /> <img /> <p>some text</p> etc.. and making sure all tags and attributes are lowercase and that attributes are quoted. Then of course you need to pick an XHTML Doctype
but either way will do
The official term is XHTML/CSS. You should code XHTML 1.0 Transitional most of the time, and make your pages validate. This allows you to use a validator as a debugger. I usually code XHTML 1.1, because it isn't much more work than XHTML 1.0 Transitional, and I can do a bit more with 1.1 pages.
I beg to differ as usual, there is no such thing as an "official term" AFAIK? - you can code CSS for HTML just as well and using an HTML Doctype you can use the validator too - IMO there is no "should code XHTML whatever" about it ;)
The idea is to choose the tool (HTML/XHTML) for the job then pick the correct Doctype to go with it then you get into the minefield of content-types ... anyway if you are interested in finding out more about the whys and wherefores of that there was an excellent discussion a while back - Why most of us should NOT use XHTML [webmasterworld.com]
Just because a page validates XHTML it does not mean it's better than the same page coded as an HTML valid page - the person doing the coding and understanding why they are using one over the other .. now that's different :)
Suzy
[edited by: SuzyUK at 5:30 pm (utc) on Feb. 17, 2007]
Please don't use XHTML 1.1 unless you're sending it as application/xhtml+xml (not recommended since IE doesn't support it).
Actually, I do, but I check the accept first.
I like it because it is absolutely BRUTAL. Even tiny mistakes result in the page being completely fubar. It forces me to write very clean code.
In any case, I've been doing this for quite some time, and my sites render on a huge range of browsers, including IE5/Win98 (and sometimes IE5/MacOS).
Because my sites have to work on such a huge range of browsers, I usually keep the "pizazz factor" pretty low, which may explain why I haven't had any issues. They are real plain, real fast, real accessible, usually (but not always) real simple and real usable.
I mainly do it because it's a challenge. I consider things like that a glove on the ground. It's become habit now.
I guess I could swap out the DOCTYPE with almost zero effort if it ever became an issue.
Another big reason is that I'd like to start moving towards XML/XSLT coding, and using things like PHP's DOM Stuff [us3.php.net] to repackage my site pages into RSS and WML pages.
Until it costs my users or myself something, I'll keep doing it. If it does cost, then I'll adapt. That's always been my M.O.
[edited by: encyclo at 1:52 pm (utc) on Feb. 18, 2007]
[edit reason] tidying up [/edit]
I started using sessions in the administration code for one of my sites, and the server was kind enough to affix a &PHPSESSID= to all of my links on the first page of the session. This is apparently done en route from the Web server to the browser, so my ob_ code cleaner can't get it.
This makes the browser go running for the porcelain convenience ("Badly-Formed" -doesn't like the "&"), so I had to back all my stuff on that site down to XHTML 1.0 Transitional and stop spitting out the header.
a) Ouch. Sounds like you need to change hosts, or figure out what’s going wrong with your setup.
Yup. I need to do some research. It only happens on my host's Apache server; not on my test server. I have a feeling it has something to do with the fact there's a hundred other sites on that server.
It's the weirdest damn thing. I scrub my HTML by grabbing it all in ob_* functions and running it through some regex functions. The &PHPSESSID isn't there when I do that, but it is there when I show the code for the page in the browser. I figured that when you echo, it goes straight to the browser. Guess not. Maybe there's something whacky with my regexes. I'll work on it a bit more...
This only happens on the first page of the session. Subsequent pages don't have it, even if I leave the site and come back, so they are tied to the browser session.
b) why Transitional? Strict would be a better fit here, especially if you’re used to coding XHTML1.1.
Yup. Transitional was easier. But I'm stubborn. I slammed all the pages back to 1.1, and skip outputing the header if it's the first page of the session. Means that I have one broken validation, but I can live with that.
My question is, will older browsers such as IE5 onwards be able to display the information of my website?
I don't have any fancy tags. Just the normal </p>, <br />, <strong>, <ul>, <li> + CSS.
1.1/1.0 Strict will work for me for a whole slew of browsers, including IE5/Win and IE5/Mac. It depends on how fancy I get with the XHTML elements and the CSS, which can break old browsers, even with HTML 4.01 Transitional.
The official story about 1.1 is that you should tell the browser the content-type is "application/xhtml+xml," if the browser will accept it.
Generally, if you won't do that, then use XHTML 1.0 Strict (basically, the same syntax, but a different DOCTYPE).
If the code will validate 1.1, then it will validate 1.0 Strict, so you can just swap out the DOCTYPE.
Here is the DTD for 1.0 Strict:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">