Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAdam Tatusko
16,589 PointsDOCTYPE
Does the DOCTYPE in <!DOCTYPE html> really need to be in all caps, as required by this code challenge? For example, view the page source for google.com.
4 Answers
Allison Hanna
36,222 PointsNope. It's case insensitive. All caps is one way that DOCTYPE can be written validly, and is a common convention. See this answer on Stack Overflow for an in-depth explanation: http://stackoverflow.com/a/9109157/5154624
Allison Hanna
36,222 PointsIf your team/company/project's style guide called for it, you'd write it in uppercase. The case, in this instance, is for human-readability only. To the computer, it is completely irrelevant. That's the nature of case insensitivity.
For contrast, and merely as an example, JavaScript is a case-sensitive language. A variable named myArr
is completely distinct from one named myarr
or one named MyArr
or any other mix of cases. Or better yet, you can define a variable using var
but not Var
. Your while loop is correctly distinguished as while
but WHILE
will error out.
Jason Anello
Courses Plus Student 94,610 PointsHi Adam,
No, it doesn't. I don't think the challenge should be requiring it.
Here's the relevant part of the html5 specification: https://www.w3.org/TR/html5/syntax.html#the-doctype
Item 1 from the first list -
- A string that is an ASCII case-insensitive match for the string "<!DOCTYPE".
Aurelian Spodarec
10,801 PointsGood practice to write uppercase since there are cases that it will need to be uppercase, but never lowercase, so uppercase should be really required for the sake of it.
Adam Tatusko
16,589 PointsPlease give me an example of a case that it would need to be uppercase?
Aurelian Spodarec
10,801 Points//Remember, the document must be served as application/xhtml+xml to trigger HTML5 in XML serialization mode. The //DOCTYPE declaration is optional in XML mode, but if you donβt want to omit it, it needs to be uppercase.
https://mathiasbynens.be/notes/xhtml5#doctype
"
No, this is incorrect. In SGML the document type declaration is production 110, in XML it is production 28. In both cases it is declared as the fixed string "DOCTYPE" (which is not a tag, it is a keyword). So in the canonical definitions in the respective SGML and XML standards it is always uppercase. If you find software that permits a lowercase "doctype" that software is not in compliance with the standards. Browsers are designed to be "liberal in what they accept", but a compliant XML processor should flag this as a validation error"
http://stackoverflow.com/questions/7020961/uppercase-or-lowercase-doctype/9109157#9109157
I use that in uppercase, it looks better for me anyways lol