Archive for the ‘xhtml’ Category
XHTML vs. HTML
Saturday, January 3rd, 2009
For all intensive purposes, XHTML is a more strict version of HTML with some of the benefits of XML. It’s goal is to be more cross-browser compatible. With that said, many of the websites I author, I still author in HTML, even though I follow 95% of the XHTML rules. Really, changing to XHTML would be pretty easy for me, because the only rule I don’t follow is I don’t close my tags that aren’t a pair. For example, I don’t close my break tags.
HTML
<br>
XHTML
<br />
For a valid XHTML document, all tags must be lowercase. I follow this already in my HTML.
Bad
<DIV ID=”sidebar”>
Good
<div id=”sidebar”>
All pages must have a valid doctype declared, which I do, I just declare HTML.
Strict declaration
<!DOCTYPE html
PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
Transitional
<!DOCTYPE html
PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
Frameset
<!DOCTYPE html
PUBLIC “-//W3C//DTD XHTML 1.0 Frameset//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd”>
Attributes can’t be minimized in XHTML, and I don’t minimize them in HTML
Bad
<option value=”MO” selected>
Good
<option value=”MO” selected=”selected”>MO</option>
Also, all attributes must be in quotes.
Bad
<table width=90%>
Good
<table width=”90%”>
Instead of using name, XHTML uses id (also notice I closed the image tag with the /.
bad
<img src=”images/myimage.jpg” name=”mainimage” />
good
<img src=”images/myimage.jpg” id=”mainimage” />
As you can see XHTML is pretty easy, not too much different from our HTML we already write. For me the transition would just require a change of habit, and really just the addition of some closing “/”s and the changing of my doctype in my site template I always start with. If it means easier compatibility then I might as well start using XHTML now.
Tags: html, xhtml
Posted in html, xhtml | 2 Comments »
