quotes in class/id names

H

Harlan Messinger

richard said:
are the quotes in like class="name" absolutely necessary?

In XHTML, yes. In HTML, not if the name consists of only letters,
digits, underscores, hyphens, periods, and colons.

But it's still good practice to use them. It makes your code more
readable, because inconsistency makes code more difficult to read. You
*will* need quotes, for example, for URLs that contain slashes, text
field values that include spaces, and so forth. It also makes the code
easier to write: you don't have to keep thinking, for each attribute,
"Wait, can I get by without quotes on this one?" It's more flexible
because, for example, you can use multiple classes as in
class="thisclass thatclass" without making them a special case.

Besides, why would you want to omit them?
 
R

richard

In XHTML, yes. In HTML, not if the name consists of only letters,
digits, underscores, hyphens, periods, and colons.

But it's still good practice to use them. It makes your code more
readable, because inconsistency makes code more difficult to read. You
*will* need quotes, for example, for URLs that contain slashes, text
field values that include spaces, and so forth. It also makes the code
easier to write: you don't have to keep thinking, for each attribute,
"Wait, can I get by without quotes on this one?" It's more flexible
because, for example, you can use multiple classes as in
class="thisclass thatclass" without making them a special case.

Besides, why would you want to omit them?

Just curious. I've run a page I'm working on through the validator and
it doesn't seem to care about that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top