开发者

Is HTML case sensitive?

开发者 https://www.devze.com 2023-01-28 16:09 出处:网络
Is HTML case sensitive? In an example I\'m working with it says: <!DOCTYPE html> Would <!doctype html> or <!DocType Html> work differently (or not at all)?开发者_如何转开发No, bu

Is HTML case sensitive?

In an example I'm working with it says:

<!DOCTYPE html>

Would <!doctype html> or <!DocType Html> work differently (or not at all)?开发者_如何转开发


No, but it's considered good practice to keep HTML markup lowercase.


From http://www.w3.org/TR/html5/syntax.html

In other words, <!DOCTYPE html>, case-insensitively.

Many strings in the HTML syntax (e.g. the names of elements and their attributes) are case-insensitive, but only for characters in the ranges U+0041 to U+005A (LATIN CAPITAL LETTER A to LATIN CAPITAL LETTER Z) and U+0061 to U+007A (LATIN SMALL LETTER A to LATIN SMALL LETTER Z). For convenience, in this section this is just referred to as "case-insensitive".


In addition to the other answers given, if you set the header Content-type: application/xhtml+xml, your browser will throw and XHML error if you don't type DOCTYPE in uppercase and html in lowercase:

<!DOCTYPE html>

Using the XHTML content type isn’t recommended because the page won't be rendered in some browsers (e.g. IE8 and below), but it's certainly interesting to know.

Source: http://blog.whatwg.org/xhtml5-in-a-nutshell


HTML is case insensitive. XHTML, that is being XML is case sensitive.


Generally, HTML is case-insensitive, but there are a few exceptions. Entity names (the things that follow ampersands) are case-senstive, but many browsers will accept many of them entirely in uppercase or entirely in lowercase; a few must be cased in particular ways. For example, Ç is &Ccedil; and ç is &ccedil;. Other combinations of upper and lower case are no good.


No, you can use any case you want.

0

精彩评论

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