HTML5 – The structure of an HTML5 document

An HTML5 document is a plain text file that contains HTML code. The code is used to structure and format the content of the web page, and to add interactive features such as links and forms.

Here is the basic structure of an HTML5 document:

<!DOCTYPE html>
<html>
<head>
  <title>Page Title</title>
</head>
<body>
  <h1>Page Heading</h1>
  <p>This is a paragraph.</p>
</body>
</html>

Here is an explanation of the code:

  • <!DOCTYPE html>: This is the document type declaration, and it tells the web browser that the document is an HTML5 document.
  • <html>: This is the root element of the HTML document. All other HTML elements must be contained within this element.
  • <head>: This element contains metadata about the document, such as the title, CSS styles, and scripts.
  • <title>: This element specifies the title of the document, which is displayed in the browser’s title bar or tab.
  • <body>: This element contains the visible content of the HTML document.
  • <h1>: This element represents a heading. There are six levels of headings (h1 to h6), with h1 being the most important.
  • <p>: This element represents a paragraph.