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

情到浓时终转凉″ 提交于 2019-12-12 18:33:55

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!