This commit is contained in:
35
site/introwebdev/week-2-doctypes.html
Normal file
35
site/introwebdev/week-2-doctypes.html
Normal file
@@ -0,0 +1,35 @@
|
||||
[!]
|
||||
[=title "Week 2: Doctypes"]
|
||||
[=content-]
|
||||
<p>
|
||||
<i>This is only a part of week 2 - make sure to read through all of the companion pieces!</i>
|
||||
</p>
|
||||
<p>
|
||||
So far we've been doing HTML pretty minimally: we just open a text file, write some tags, save, and reload.
|
||||
This is all well and good, but there's a subtlety: when you just enter html immediately, the browser
|
||||
<i>has no idea what you're doing</i>. Browsers are pretty smart, so it <i>guesses</i> (by the filename,
|
||||
and by the presence of tags) that it's HTML, but the browser also guesses that you aren't really using
|
||||
HTML properly, and so some features are broken!
|
||||
</p>
|
||||
<p>
|
||||
This situation is known as <i>quirks mode</i>. It's actually mostly fine - most of the features that it breaks are pretty obscure -
|
||||
but to maintain full compatibility and avoid weird bugs, we should always declare an HTML5 doctype. In fact this is very easy. Just include the following
|
||||
tag at the top of all of your html files:
|
||||
<pre><code><!DOCTYPE html></code></pre>
|
||||
</p>
|
||||
<p>
|
||||
This will put your page into standards mode, ensuring correct HTML5 non-quirks behavior.
|
||||
Do not include any text on the same line, so your files should look like
|
||||
</p>
|
||||
<pre><code><!DOCTYPE html>
|
||||
<h1>Header!</h1></code></pre>
|
||||
<p>
|
||||
Instead of
|
||||
</p>
|
||||
<pre><code><!DOCTYPE html><h1>Header!</h1>
|
||||
</code></pre>
|
||||
<p>
|
||||
I <b>will not accept</b> any homeworks that don't have a correct doctype. Make sure to memorize the pattern!
|
||||
</p>
|
||||
[/]
|
||||
[#template.html]
|
||||
Reference in New Issue
Block a user