Home » Html » Is HTML case sensitive?

Is HTML case sensitive?

Posted by: admin November 30, 2017 Leave a comment

Questions:

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)?

Answers:

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

Questions:
Answers:

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

Questions:
Answers:

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

Questions:
Answers:

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

Questions:
Answers:

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.

Questions:
Answers:

No, you can use any case you want.