开发者

Is it necessary to use lowercase for every Element and attribute , properties in css and xhtml ?

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开发者_JAVA技巧 for every thing?


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


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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜