Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

HTML vs XHTML

Featured Replies

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.

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 . . . .

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

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.

  • Author

Thanks for the great replies guys...

 

Will definitely look further into it!

  • Author

And how about XHTML Strict and Transitional? Which one is better, are there many differences between both?

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... :p

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

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! ;)

  • 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!

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.

  • 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.

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.

  • Author

Ah ok, I see!

Thanks MrB

Ah ok, I see!

Thanks MrB

 

 

No problem.

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.