How to set up smartphones and PCs. Informational portal

Basics of html. General rules

In this chapter:

Element syntax

HTML element is the basic structural unit of a web page written in the HTML language. The image below demonstrates the syntax of the elements. For most tags, the element syntax will look the same except for single tags.

All elements in HTML follow the same format:

  • The element starts with a start tag.
  • The element ends with a closing tag.
  • The content of an element is everything between the opening and closing tags.
  • Some elements have no content (empty elements).
  • Most elements can contain attributes

Note: do not forget to put the " / ", it tells the browser that your element has ended and that what will be written after it is already another element.

Empty elements

There are several elements in HTML that do not have an end tag, for example or
... Such elements are called empty because they do not contain any content and do not have an end tag.

Nested elements

All HTML documents are composed of nested elements. Most of them can either contain other elements, or they themselves can be nested in other elements, while the depth of nesting of elements is not limited.

The following example has three elements, two of which are nested:

My first paragraph

When nesting one element within another, be careful to ensure that the nested element starts and ends within the same element. So, the following example is incorrect:

This very

interesting

There are two types of elements in HTML - block elements and inline elements. Below you will learn the features of these elements and the difference between them, as well as ways to control them through CSS rules.

Block elements

Block elements are the basis that is used for the layout of web pages. Such an element is a rectangle that by default occupies the entire available page width (unless otherwise specified in CSS), and the length of the element depends on its content. Such an element always starts on a new line, that is, it is located under the previous element. A block element can contain other block and inline elements.

Examples of block elements:

,

,