问题
4.2. Element and attribute names must be in lower case
XHTML documents must use lower case for all HTML element and attribute names. This difference is necessary because XML is case-sensitive e.g. <li> and <LI> are different tags.
Source : http://www.w3.org/TR/2002/REC-xhtml1-20020801/diffs.html#h-4.2
But is it also necessary for attributes, properties, values, class and ID for elements.
Upper case and came case should not be used.
What is the benefit of use lowercase for every thing?
回答1:
What is the benefit of use lowercase for every thing?
There are a few good reasons:
- simplifies implementation; you'll only have to look for one variant to match a tag, not all its case-sensitive variants, for example
- easier to type, if needed; humans appreciate things that save them effort
- one consistent way to do everything
- lower cognitive overhead about whether this tag should be capitalized or not
回答2:
The only real benefit is that your webpage will be XHTML compliant. Browsers are built on the philosophy of "Be conservative in what you emit and liberal in what you accept", and doing crazy capitalization things should not throw any of them (except maybe IE, but that's a whole other battle)
As for theoretical benefits, it saves time/effort for developers, but AFAIK, browsers don't care, so...
来源:https://stackoverflow.com/questions/2115157/is-it-necessary-to-use-lowercase-for-every-element-and-attribute-properties-in