Getting the start of HTML pages right
Let’s consider the opening elements of an HTML page and ensure we fully understand all the essential component parts.
Like so many things with the web, remembering the exact syntax of each thing inside the head
section is not particularly important. Understanding what each thing is for, is. I generally copy and paste the opening code each time, or have it saved in a text snippet, and I would recommend you do too. The first few lines in an HTML page should look something like this:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
The doctype
So, what do we actually have there? First of all, we opened our document with the HTML5 Doctype declaration:
<!DOCTYPE html>
If you’re a fan of lowercase, then <!doctype html>
is just as good. It makes no difference.
The HTML tag and lang attribute
After the Doctype declaration...