HTML and CSS Reference
In XHTML, all attribute values are quoted, even those that don't contain whitespace.
Absolutely no browsers are in the least bit confused by a properly quoted attribute value.
This can add roughly two bytes per attribute value to the file size. If you're Google and are counting every byte
on your home page because you serve gigabytes per second, this may matter. This should not concern anybody
Manually, all you have to do is type a single or double quote before and after the attribute value. For example,
consider this start-tag:
<a class=q href=http://www.example.com>
You simply turn that into this:
<a class="q" href="http://www.example.com">
<a class='q' href='http://www.example.com'>
There's no reason to prefer single or double quotes. Use whichever one you like. Mechanically, both Tidy and
TagSoup will fill these quotes in for you. It's probably easiest to let them do the work.
Regular expressions are a little tricky because you also need to consider the case where there's whitespace
around the equals sign. For instance, you don't just have to handle the preceding examples. You have to be
ready for this:
<a class = q href = http://www.example.com>
And even this:
Finding the cases without whitespace is not too hard. This will do it:
However, the preceding code snippet will also find lots of false positives. For instance, it will find this tag
because of item=15314 in the query string: