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 trialSerdar Halac
15,259 PointsWhy did layout.html have '<!doctype html>' at the top but course_list.html did not?
As the title says. Isn't it standard procedure to put <!doctype html> on ALL html files? Why did we previously not put it in the course_list.html file?
Here is the course_list.html code:
{% for course in courses %} <h2>{{ course.title }}</h2> {{ course.description }} {% endfor %}
And here is the layout.html code:
<!doctype html> <html> <head> <title>{% block title %}{% endblock %}</title> </head> <body> {% block content %}{% endblock %} </body> </html>
Why does one have the doctype line, and the other does not?
The weird thing is they both worked on the browser! So what gives?
1 Answer
Kieran Barker
15,028 PointsIβm not sure why only one had the <!DOCTYPE html>
declaration, but I can tell you why they both worked. As of HTML5, you donβt have to include it β although it is still best practice to do so. Nor do you have to include <body>
(or <head>
, I think) because it is just assumed. Another thing in HTML5, for example, is that you donβt have to close some elements. For instance, this would be valid in HTML5:
<p>No closing tag
I hope this helps!
Serdar Halac
15,259 PointsSerdar Halac
15,259 PointsIt does! Thank you for your answer. Did not know that about HTML5.