The structure and syntax of an HTML document
An HTML document is a text file with a name ending in .html
, for example, hello.html
. A modern, minimal HTML document looks like this:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"/> <title>Hello, world</title> </head> <body> <h1>Hello, World</h1> </body> <html>
Doctype
The first line specifies the document type (<!DOCTYPE html>
). Today, this can be as simple as the word html
telling a browser that this file is to be interpreted as an HTML5 document. Documents written to the older specifications contain the name of that spec followed by a path to a Document Type Definition (DTD) file that can be used to examine the document for conformance. Things are a lot more flexible these days.
<html>
This is the root of the document. Everything in the remainder of the document will be inside this html
tag. What is inside the html
tag consists of two sections, the...