What is the difference between a single tag and a double tag? Paired tags. What's new in HTML5 in terms of tags
HTML (HyperText Markup Language) is a hypertext markup language. Markup language is used to give structure to an Internet page or website. The markup language does not carry design, but performs structuring tasks. The structure is set using special elements - labels that are understandable to the browser. These tags are called tags - from the English. words tag - named tag.
Hypertext is a document whose markup is made using the HTML language. The term “hypertext” was originally coined by Ted Nelson to refer to text “that branches out on itself or performs an action on demand.”
An HTML document is a regular text file that has a special structure. When opened, the Internet browser processes this document, as a result of which we see the Internet pages that are familiar to us, where there is text, pictures, links, etc. Internet pages have the extension – html.
Let's look at the structure of a simple HTML document
Document
Document
|
The string is called a tag. In general, everything that is enclosed in characters is called a tag. These symbols are service symbols in the HTML language. There are two types of tags:
- Paired - these tags have an opening and a closing tag. The closing tag contains a slash character. The contents of the tag are written between these tags. The content of a tag can be either plain text or other nested tags. Examples of paired tags:
- Unpaired - tags that are not closed. Example:
Tags can be written in capital or small letters, since HTML does not differentiate between spellings. You should always close paired tags!
It is considered good form to know and be able to operate with a large number of tags. There is no need to be afraid of this, everything will be remembered and fit into your head as soon as you begin to apply your knowledge in practice. We will become familiar with the main tags in the course of our further training. In general, a huge number of reference books on HTML are now available on the Internet, where you can find up-to-date information, because progress does not stand still, and programming languages are developing rapidly and updates are coming out almost every six months. Also, you will find the minimum tags that we will need during the training in our cheat sheet
Let's look at the structure of the HTML document:- — what kind of tag is this? This is the version of HTML that is used on this page. It is customary to start all HTML documents with a similar tag. This is considered good manners. DOCTYPE tells the browser what version of HTML the document was written in, so that all browsers (and there are many of them now) can correctly process the markup and display the contents of the document. If this is not done, the default browser will incorrectly determine the version of the document, as a result of which all markup may move and display incorrectly in different browsers. In this case, DOCTYPE indicates the HTML5 version.
- - all the content of the page is enclosed between these paired tags, which inform the browser that this is an HTML page.
- -service section (header), which is used to connect external files and settings responsible for the appearance, output and operation of this page. Its content is most often not displayed on the page, except for the title tag. title tag – contains the title of the page, which is displayed in the tab.
- — everything that is displayed on the page is written in the body tag.
To expand the functionality of HTML, special information called attributes is added to tags. So in the line:
|
charset="UTF-8" - attribute. There can be many attributes. Attributes are written separated by spaces. In this case, using the meta HTML tag, the UTF-8 encoding is indicated on the page. Those. The browser is told the encoding of this document to correctly display the contents of the page.
Attributes are used to extend the functionality of tags and allow you to modify both the way tags are displayed on a page and their behavior. Not all tags are used to display information; there are tags that are used only to program the behavior of the page, for example using JavaScript.
Questions for self-controlThe text of the lesson was developed jointly with Kamenschik M.
A tag is a special reserved word enclosed in angle brackets (for example, ). A tag is the main component of HTML: the code begins with it, it ends with it, and the information displayed on the web page is contained within the tags. It is recommended to write them in lowercase, that is, in ordinary small letters: not, but.
What are the types of tags?Most HTML tags are paired: there is an opening tag (for example, ) and a closing tag, which is distinguished from the opening tag by a slash (/) after the first angle bracket (for example, ). Everything that is inside a pair of tags is called their content.
Contents Text placed inside these tags becomes bold
There are also unpaired (single) tags, which are called tags. They, unlike paired tags, do not need to be closed, because they do not work with the content, but perform some function on their own. Example of a single tag -
. It sets the text to wrap to the next line.
If we draw parallels with the Russian language, we can say that paired tags are quotes or brackets that affect the properties of the text contained in them (try not to close the quotes in time), and single tags (marks) are punctuation marks (exclamation, question or dot).
Any tag consists of:
- Open angle bracket (< ).
- A special word (tag name). For example, hr , iframe , b .
- Closing angle bracket (> ).
Since tags are the basis of markup language, it is not surprising that there are quite a lot of them. Let's look at the main, most important tags.
- - a single tag containing a comment. A comment is text that is not processed by the browser. You can write whatever you want inside the tag, even other tags - they will not work, they will not appear on the screen. Developers comment on the code either to make it easier for other webmasters to understand it, or so that after a long time they can quickly understand it themselves.
- , , , , are tags that should be present in any decent HTML document (for more details, see “How to Create a Website in Notepad”).
- - the tag contains auxiliary information for browsers and search engines. Inside it you can write keywords, page description, document encoding, author's name, etc.
- contains a link to the script file or the code itself.
- - a tag that sets the style of the document and/or its elements using CSS. An HTML document can contain many tags that define different styles for different parts of the page.
- - the complete opposite, complementing it. The tag specifies the “header” (title) of a section or the entire page.
- stores the “legs” of a site or section. Inside it you can place supporting information, copyright, contact information, etc.
- contains the main content of the page. Neither the header, nor the menu block, nor the “legs” of the site, but what the page was created for. For example, on the page you are reading now, this article should be located inside.
- designed for creating links. Links are the root of hypertext, which is why this article is dedicated to them.
- needed to add pictures to a web page (at your service is dedicated to this action).
-
,
, - , , ,, , , and other text formatting tags make up a large group of HTML tags; they are discussed in the article “Formatting Text in HTML”.
- - block element. The text inside is formatted using CSS (cascading style sheets, which is the subject of the second part of the tutorial).
- . You have a paragraph
or block . The text in it is designed in the same style, but you would like, without disturbing the structure, to make sure that several words have a different font size or color. It is for such situations that the tag is intended.
-
,
-
,
- - list tags. Marked, numbered - the work of these tags. There are also lists of definitions for which the tags are responsible, and, but you will learn in detail about all six of these in the article “Creating Lists”.