Single and double tags. Tags in HTML

You have already read that the entire language is made up of tags. In this tutorial, we'll take a closer look at HTML tags. In the HTML language, tags are divided into single (not paired) and paired tags. So, single HTML tags consist of one tag, that is, they do not have a closing tag. And paired descriptors have an opening and closing tag.

Single HTML tags

Single tags do not have a closing tag. For example:
, . It used to be written like this:
, , now this style of writing single tags is not relevant, so don't write like that. Most used single tags:
- wrapping to a new line,


- Demarcation line, - insert image.

Paired HTML tags

Paired tags a lot more. The pair descriptor has an opening and closing tag. The pair tag forms a container. The content of the container is what is between the opening and closing tag. In the example from this article, you saw the tag

What are tags in HTML?

, so, this is a pair tag, the content of this tag is the text "What are tags in HTML?". Its beginning is the tag

, and the end

.

The main mistake of beginners in writing paired tags is confusion in nesting. For example, this is the correct entry:

Bold paragraph

. And here is the error:

Bold paragraph

, an HTML document with such layout is not considered valid. In order not to confuse nesting, do this: create paired tags, then put others in them, and at the end write text inside both tags

How to write pair tags correctly

.

What's new in HTML5 in terms of tags?

HTML5 language is an extension of HTML4, so it kept most or all of the tags from HTML4 and added its own. HTML5 introduced special tags to break the site into main blocks: header, menu, footer, sidebar and content.

Why is it important to learn how to use tags?

Search engines Yandex and Google are sensitive to the layout of HTML documents, checking them for validity. They look for keywords enclosed in special descriptors and so on. But this section is not about that. This applies to promotion (SEO).

How to learn all HTML tags?

Yes, there are a lot of tags. But there is no need to specifically teach them. While you practice writing something, all the descriptors, paired and single, will be easy to remember. Over time, of course.

An HTML element is the basic structural unit of a web page written in HTML.

Paired and single HTML tags

HTML Syntax elements consisting of paired tags:

  • 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. The content can be text and/or another HTML element.

Note: do not forget to put the symbol "" in the closing tag / ", it tells the browser that your element has ended and that what will be written after it is already another element. If you do not put the character " / " in the closing tag, the browser will interpret it as new element, nested in the previous one, which, according to the browser, is still not closed.

The syntax for HTML elements consisting of single tags is:

  • The element consists of only the opening tag.

Elements consisting of single tags are called empty. There are 16 single tags in HTML:

Nested elements

HTML elements consisting of paired tags can either contain any other elements, or they can be nested inside other elements, while the nesting depth of elements is not limited.

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

My first paragraph



When one element is nested within another, care must be taken to ensure that the nested element starts and ends inside the same element. So, for example, the following code is incorrect:

it very

interesting

Here element goes outside the element

Example with correct nesting:

it very interesting

Here element correctly nested - it is completely within the element

Whitespace characters

The browser ignores whitespace characters in HTML code, so you can use them to your advantage by making your code readable. Whitespace characters include: tab characters, line breaks, and regular spaces, they can be used in any quantity. Example code that uses whitespace characters:

header

My first title

My first paragraph



The example code could have been written without using whitespace characters, but code like this would be less readable:

header

My first title

My first paragraph

As the code in an HTML document gets larger and more complex over time, it becomes clear that using whitespace actually improves the readability of the code.



HTML tags is the basis of the HTML language. Tags are used to delimit the start and end of elements in markup.

Every HTML document consists of a tree of HTML elements and text. Each HTML element is identified by a start (opening) and an end (closing) tag. The start and end tags contain the tag name.

All HTML elements are divided into five types:

  • empty elements , ,
    , , ,
    , , , , , , , , , ;
  • plain text elements