#native_company# #native_desc#

XHTML: Why You Should Be Using It Page 2

By PHP Builder Staff
on June 29, 2009

What is that about the name attribute not validating
anymore? Well, it’s simple: the name attribute has
been deprecated in favor of the id attribute.
However, as said before – if you are using the
transitional DOCTYPE you can use the name
as well as the id attributes together, like this:
<div name="something" id="something">
Doing it like that means that older browsers that do not
recognize the id attribute will still render the
content, albeit oddly (My own opinion is that anyone using a
browser older than IE6 or Firefox 2 deserves to have a bad
internet experience, but hey–that’s just me).
Something I am sure you have noticed already is that my tags are always written
in lower case. Upper case tags in XHTML are taboo. Stick to lower case
and all will be fine. Another thing you may or may not have noticed is that my
tags are not minimalized. Minimalization means that this is right:

<input type="text" readonly="readonly" />
while this is wrong:

<input type="text" readonly />
The idea is that the attribute value is the same as the
attribute name, so




Now I’m sure that another thing rearing its ugly head here–
at least for me–is the fact that all atttribute values are
quoted. This is important. The following is wrong:

<input type=text readonly=readonly />
while this is right:

<input type="text" readonly="readonly" />
Both single quotes or double quotes are fine as long as all
attribute values are quoted. My obsessive-compulsive mind
goes thorugh stages of preferring single quotes over double
quotes and vice-versa. But whichever I use, I try to be
consistant. God is in the Mark-Up.
Before calling it a day–and before you fall asleep due to
over-exposure–there are just a few minor things to look at.
First, the structure of an XHTML page. The basic elements
required in an XHTML page follow:

<!DOCTYPE ...>



<title>... </title>


<body>... </body>

They are ALWAYS required in the order shown above. More
elements can be added as need be, but these cannot be taken
Last, but not least, always Validate Your Pages with
the W3C Validator. This handy tools checks your pages and
even tells you how to fix the problems.
Until next time, Happy Validating!
Marc Steven Plotz