I've noticed a lot of people who don't use quotation marks when they write HTML. For example:
<li class=somename>blabla</li>
instead of
<li class="somename">dkdk</li>
Where are they getting this from?
I've noticed a lot of people who don't use quotation marks when they write HTML. For example:
<li class=somename>blabla</li>
instead of
<li class="somename">dkdk</li>
Where are they getting this from?
Before XHTML, you were allowed to not use quotations; and in fact browsers have been coded to be as lenient as possible. With the advent of XHTML, it is no longer convention, but browsers still recognize it.
From the HTML 4.01 specification:
In certain cases, authors may specify the value of an attribute without any quotation marks. The attribute value may only contain letters (a-z and A-Z), digits (0-9), hyphens (ASCII decimal 45), periods (ASCII decimal 46), underscores (ASCII decimal 95), and colons (ASCII decimal 58). We recommend using quotation marks even when it is possible to eliminate them.
But in XHTML quotation marks are required to be well-formed XML (see also XHTML 1.0: Differences with HTML 4 – Attribute values must always be quoted).
Well, there is a history to this stuff. There is a reason why HTML iin the wild is tag soup. It has to do with the whole "be liberal with what you accept" stuff. A lot of those people started doing web design before XHTML got to be really popular. Also, some older HTML WYSIWYG editors probably default to that ugly syntax.
I feel it all depends on who taught them or how much they are interested in coding. If you think your code should look neat. You will automatically start following best practices.
People tend to do things with the least effort, so while nearly every browser and parser accept the first version, they keep on producing "invalid" html.
The short answer is because not everyone cares about whether they follow good practices with their code or whether it meets the official specifications provided by the W3C (ie can validate).
That said, there is a point where you have to call it good enough. See this recent post from Jeff Atwood.
Many WYSIWYG Editors do not add Quotes, IntelliSense in Visual Studio does not add Tags, people may wonder what the point is in adding tags if they are unneeded. After all, they also require bandwidth.
I always use Quotes, but there is really no reason to use them other than for code-style and if you need to use something like class="one two three".
Maybe because its quite normal to be imperfect but its abnormal to be perfect. Human nature, buddy !