December 16, 200817 yr Hi guys. I currently design all my sites in HTML <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> But I've noticed that most sites are now done in XHTML Strict 1.0 What are the advantages of using XHTML over HTML? Thanks.
December 16, 200817 yr XHTML is fast becoming the standard for websites. It's very similar to HTML but stricter... For example: <a HREF="alink">LINK</a> is valid HTML but not XHTML... In XHTML it would read: <a href="alink">LINK</a> in other words all 'code' should be lower case. There are plenty of other examples but in general it's pretty easy to progress from HTML to XHTML... And, we all know that up to date valid sites rank higher in search engines . . . .
December 16, 200817 yr Hey, The Differences - (Quick answer taken from w3schools): XHTML elements must be properly nested (eg. <strong><u>Hello</u></strong>, and not <strong><u>Hello</strong></u> XHTML elements must always be closed (eg. <b>Hello</b>,not just <b>Hello XHTML elements must be in lowercase (As Satin pointed out above) XHTML documents must have one root element <!DOCTYPE> Is Mandatory Attribute names must be in lower case Attribute values must be quoted Attribute minimization is forbidden The id attribute replaces the name attribute Here's a more thorough explanation on why XHTML is better: Link
December 16, 200817 yr Essentially, XHTML is guaranteed to be valid XML. This makes parsing XHTML pages much easier because they don't have to do "clean up" on bad code (like unclosed tags, and <br>s which should really be <br /> etc.) This can speed up loading of the page on low-power devices like mobile phones. XHTML also does a decent job at removing all styling elements (<b>, <i>, <strike> etc.) in favour of CSS, leaving only the semantically important ones from HTML (<strong>, <em>, <del> etc.). This forces developers to write code which can be understood by other types of user agents like aural parsers and braille (for the blind). XHTML has also been modularised, making it easier to "plug-in" support for new elements. Thus certain small devices like mobile phones can choose to support some modules but not others, and make it clear which modules they support so developers can ensure compatibility. XHTML Basic is an example subset of XHTML elements for small devices. XHTML provides the right solution for wireless development is an article on these lines. You can also read the XHTML FAQ.
December 16, 200817 yr Author Thanks for the great replies guys... Will definitely look further into it!
December 18, 200817 yr Author And how about XHTML Strict and Transitional? Which one is better, are there many differences between both?
December 18, 200817 yr And how about XHTML Strict and Transitional? Which one is better, are there many differences between both? Ok, this is a good subject. Well I know this might not be a 100% correct, but I could have sworn that I read something about html eventually fading out. Xhtml is supposed to takes its place. I am not sure if this is true, but I am pretty sure that I read this somewhere and I cant remember where at the moment. XHTML Strict vs Transitional I would highly recommend using transitional mainly because it is easier to code. I dont like using strict cause I remember getting a headache cause of certain tags or something being off in strict. So while using the same codes I used in strict, i tried them in transitional and everything was good! So I would highly recommend xhtml transitional. I hope it didn't seem like I was just rambling...
December 18, 200817 yr And how about XHTML Strict and Transitional? Which one is better, are there many differences between both? Strict - as the name suggests - is a more restrictive DTD when it comes to markup validation. Kinda depends on your idea of 'better', but in the sense of 'cleaner' and 'more correct' then Strict is your answer. Transitional is there more for backward compatibility reasons than anything else. So in short - if you want your code fully standard compliant - use Strict. Check this out for a quick summary of differences.. http://www.aptana.com/docs/index.php/About...DOCTYPE_in_HTML and this for more details.. http://www.zvon.org/xxl/xhtmlReference/Out...comparison.html
December 18, 200817 yr Browsers have good compatibility with XHTML 1.0 Strict. This is also almost true of XHTML 1.1 (which is almost identical to 1.0 Strict) except for some MIME problems on IE. Since next generation XHTML is going to look like XHTML 1.1, I work by the philosophy that it's good to provide "forward compatibility"---so pages written in XHTML 1.0 Strict or 1.1 won't require many changes to work under future standards like XHTML 2.0. There are going to be some useful structural elements appearing in that spec., like navigation lists (<nl>), removing anchoring (<a>) in favour of more generic hyperlink attributes, and XForms. Pages written using Transitional will potentially require a huge overhaul; let alone having to hunt down and change bits of HTML embedded in server-side code. Perhaps looking five years down the line shouldn't present a huge concern, but if I can save myself work later by using XHTML 1.0 Strict or 1.1, I'll do it!
December 18, 200817 yr Author Riiiight! Well Ive been working on HTML 4.01 Transitional and never had a problem Thanks for the replies guys. I will start working with XHTML 1.0 Strict. One quick question, i though that in HTML we could open a div and close it like this: <div class="clearFix" /> or does it have to be like this: <div class="clearFix"></div> Thanks!
December 18, 200817 yr One quick question, i though that in HTML we could open a div and close it like this: <div class="clearFix" /> or does it have to be like this: <div class="clearFix"></div> Thanks! Either should be valid.
December 18, 200817 yr Author Ok, it is valid, but its not looking right. EG i have: <div id="colLeft" /> <div id="colRight"> "...content here..." </div> The way above, it shows as if colRight is inside colLeft if i chage to: <div id="colLeft"></div> Then everything works. Bare in mind, colLeft and colRight are floating Right.
December 18, 200817 yr Ok, it is valid, but its not looking right. EG i have: The way above, it shows as if colRight is inside colLeft if i chage to: Then everything works. Bare in mind, colLeft and colRight are floating Right. Yea, better use the full open/close form here. div is not implicitly an empty tag afterall. The browser can get confused with those. The short form should still be fine with tags like meta, link, img etc though.
December 18, 200817 yr Ok, it is valid, but its not looking right. May I ask which browser the problem is on? Or all of them? I see no reason why the expanded form should be any different to the empty tag short form. XML defines them to be the same thing, so standards compliant browsers must treat them identically. If it's Internet Explorer we're talking about though, anything is possible!
Create an account or sign in to comment