HTML document structure

HTML documents are plain text files with an html or htm extension. So any editor can be used to create text files, which allows you to create an ASCII text file. Of course, there are a number of specialized programs to facilitate the creation of this type of document. One of their most important features is the syntax coloring, automatic tag closing, display of hints and other features that facilitate efficient code entry.

Whichever editor you choose, the document should have an appropriate structure, which consists of the headline and the main body of the document. In its simplest form, the skeleton of an HTML document might look like this:

 
<html>
<head>
</head>
<body>
</body>
</html>

It is a very simplified structure consisting of three tags <html>, <head> i <body>. Marker <html> it includes all tags and frames the html document. Inside the item <head> there is a document header, which should contain the tags describing the document. A pair of tags <body> in turn, it determines the main part of the document, the so-called body (ang. body - the body).

The presented structure should be expanded with additional elements, required by the standards currently in force. The first such element is the document type definition of the DTD.

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict // EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Page title</title>
</head>
<body>
</body>
</html>

The second is the element's xmlns attribute <html> informing, that it is an XHTML document.

The declaration of the document type informs the web browser according to. what rules the given HTML document was created. On the website of the W3C organization, dealing with the development of web standards, there is a list recommended types of documents. Element <title> is responsible for the title of the document. For a website, the title will be displayed in the title bar of the web browser window.

Meta elements are placed inside the header section, which define the properties of an HTML document, including. how the document is encoded, description of the content, specify the author or provide other additional information.

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict // EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
  <meta http-equiv="Content-Language" content="pl" />
  <meta http-equiv="Reply-To" content="adres_email[monkey]serwer.pl" />
  <meta http-equiv="Creation-Date" content="Thu, 25 Dec 2008 10:36:53 GMT" />
  <meta name="Description" content="description of the content" />
  <meta name="Keywords" content="words, key" />
  <meta name="Author" content="q3d" />
  <meta name="Robots" content="all" />
  <title>Page title</title>
</head>
<body>

The originally simple structure was expanded with a few additional elements . One of the key ones is:

 
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />

specifying the character encoding used in the text editor, which was used to prepare the document.

Header fragment:

 
  <meta http-equiv="Content-Language" content="pl" />
  <meta http-equiv="Reply-To" content="adres_email[monkey]serwer.pl" />
  <meta http-equiv="Creation-Date" content="Thu, 25 Dec 2008 10:36:53 GMT" />

informs accordingly about: the language of the document, the author's email address and creation date. Elements:

 
  <meta name="Description" content="description of the content" />
  <meta name="Keywords" content="words, key" />

in the past they were used by search engines to index a website, at present, however, they are of less importance. Additionally, the element:

 
  <meta name="Robots" content="all" />

allows web crawlers to index the document.

HTML documents often use external files, including. storing information about formatting the appearance of the document and an icon symbolizing the document. These files are attached using the element <title> with the appropriate value for rel.
The following example, making the required modifications, can be used to create more HTML documents.

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict // EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
  <meta name="Description" content="description of the content" />
  <meta name="Keywords" content="words, key" />
  <meta http-equiv="Content-Language" content="pl" />
  <meta name="Author" content="q3d" />
  <meta http-equiv="Reply-To" content="adres_email[monkey]serwer.pl" />
  <meta http-equiv="Creation-Date" content="Thu, 25 Dec 2008 10:36:53 GMT" />
  <meta name="Robots" content="all" />
  <title>Page title</title>
  <link rel="Shortcut icon" href="page_icon.ico" />
  <link rel="Stylesheet" type="text/css" href="style.css" />
</head>
<body>

One thought on ÔÇťHTML document structure”

  1. Hi, if someone is interested in the topic of the article – then we invite you to trainings in HTML and CSS at itschool.pl ­čÖé

Leave a Reply

Your email address will not be published. Required fields are marked *