How to set up smartphones and PCs. Informational portal
  • home
  • Safety
  • Basic HTML tags. How are unpaired tags different from paired tags? Paired and unpaired tags

Basic HTML tags. How are unpaired tags different from paired tags? Paired and unpaired tags

Tag (pl. tags, sometimes tag) Is an HTML element used to mark up the source text of a web page. Tags are abbreviations or abbreviations of English words enclosed in angle brackets<>e.g. tag

shorthand for the English word paragraph, that is, the text enclosed in this tag will be recognized by browsers as a paragraph.

Each tag in HTML has a special meaning and is responsible for displaying certain data. The case of letters in tag names does not matter, for example, tag

and the tag

- This is the same. That is, tags can be written in both lowercase and uppercase letters. It used to be generally accepted that all tags should be written in capital letters to distinguish tags from normal text. Now there is no such need, since many editors have syntax highlighting.

Tag classification

There are more than 90 tags in HTML in total. As a rule, one tag affects only part of the document, for example, the first level heading tag

... In such cases, paired tags are used: opening and covering... Opening tag (for example,

) creates the effect, and the closing (

) - terminates its effect. As you can see from the example, the closing tag always has the following symbol ( / ) - forward slash. Such tags are called paired.

Some tags have a one-time effect where they appear. For example, the horizontal bar tag


or picture display tag ... Such tags do not have end tags. Such tags are called non-paired tags.

Types of tags

In addition, tags are divided into several types, which differ in their functions:

  • document title tags;
  • block elements;
  • inline elements;
  • universal elements;
  • lists;
  • tables;
  • frames.

This division is not strict, so some tags are in different groups. For example, tags for creating lists

    and
      apply to both lists and block elements.

      Tag structure

      When loaded in a browser, the tags themselves are not displayed, but affect the way their content is displayed. If there is a mistake in the spelling of the tag, it is ignored entirely.

      All tags have a specific structure that must be followed when writing. In addition, almost all tags have various attributes that can change the way the content is displayed.

      Let's take a look at the correct structure of tags containing attributes:

      1. Himself Webmaster

      As an example, I gave two completely different tags. First single - is responsible for displaying images, attribute - src = "logo.jpg"... Second paired is responsible for creating links, attribute - href = "site".

      Conclusion 1: Attributes can have paired and unpaired tags.

      Conclusion 2: Attributes can only have opening tags, closing tags have no attributes.

      Picture for clarification:

      HTML is a plain text file with the extension .htm (html). To create the simplest page at first, when you are just practicing, you only need a notebook. Open notepad and write some text.

      Each HTML element is a tag framed by<>brackets. Any file, html page starts with a tag and ends with the tag.

      This tag simply tells the browser (this is the program in which you are browsing the web) that the given document is an html markup document.

      Tag - means the beginning of an html document, and- closing tag means the end of the html document.



      There are several other important tags inside these tags. Immediately following the tag there are tags that mean the title of the page and the body of the page.


      My first HTML page




      Tag means the title of the window title when displaying this page. <br>Now you can create a new text document in notepad, copy the text presented above and save it as Page1.html and run it in the browser, you will see the title of the page from <title>, and a blank page, because we are in the body of the page in tags <body> </body> do not display anything.</p> <p>So, the above text will be the basic skeleton of any web page for us.</p> <h4><b>Paired and unpaired tags!</b></h4> <p><html></html>, <head></head>,<body></body> These are just paired tags - those tags that go as a pair of a tag and its closing, the closing tag with a /. For paired tags, the value between the start of the tag and the end of the tag is the action of the tag. The action will propagate until a tag with the / character is found.</p> <p>Unmatched tags - they don't have an end tag. We will provide examples of such tags below.</p> <p><head></head>- The heading of the html page, which includes keywords for search engines, various scripts, etc.</p> <p><body></body>- Directly the body of the html document.</p> <p><br />Unpaired tag.</p> <p><b>Note:</b> In most cases now, when building sites, they use ready-made routines, plugins, etc. - for faster creation of sites, but in order to apply and use such routines and templates - a minimum knowledge of these sessions is still required.</p> <p>HTML (HyperText Markup Language) is <b>hypertext markup language</b>... The markup language is used to give structure to the Internet page, site. The markup language does not carry the design, but performs the tasks of structuring. The structure is set using special elements - labels that are understandable for the browser. These labels are called tags - from the English. the words <i>tag - a named tag.</i></p> <p>Hypertext is a document marked up with <b>HTML language</b>... The term "hypertext" was originally coined by Ted Nelson to refer to text "that forks on its own or performs an action on demand."</p> <p>An HTML document is a plain text file that has a special structure. When you open the Internet browser processes this document, as a result of which we see the usual Internet pages for us, where there are text, pictures, links, etc. Internet pages have the extension - <i>html</i>.</p> <p>Consider the structure of a simple HTML document</p> <p><!DOCTYPE html> <html lang="ru"> <head> <meta charset="UTF-8"> <title>Document

      Document

      Line called a tag. In general, everything that is enclosed in symbols<>called a tag. These characters are service characters in the HTML language. There are two types of tags:

      • Paired- these tags have an opening and closing tag. The closing tag contains a forward slash character. The content of the tag is inserted 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 uppercase and lowercase because HTML does not distinguish 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. This does not need to be scared, everything will be remembered and will fit in your head as soon as you start to apply your knowledge in practice. We will get to know the main tags in the course of our further training. In general, a huge number of HTML reference books are now available on the Internet, where you can find up-to-date information, because progress does not stand still, and programming languages ​​are rapidly developing and updates are released almost every half a year. Also, you will find a minimum of tags that will be necessary for us during training in our cheat sheet.

      Consider the structure of an HTML document:

      • - what is this tag? This is the HTML version used in this page. It is customary to start all HTML documents with a similar tag. This is considered good practice. DOCTYPE tells the browser in which version of HTML the document was written, so that all browsers (and there are many of them now) can correctly process the markup and display the content of the document. If this is not done, then the default browser will incorrectly determine the version of the document, as a result of which all the markup can go and display incorrectly in different browsers. In this case, the DOCTYPE indicates the HTML5 version.
      • - all page content 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, most often, is 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 is added to the tags, which are called attributes. So in the line:

      charset = "UTF-8" - attribute. There can be many attributes. Attributes are separated by a space. In this case, using the meta HTML tag, the page is specified as UTF-8 encoding. Those. the browser is indicated with the encoding of this document, for the correct display of the page content.

      Attributes are used to extend the functionality of tags and allow you to modify both the way tags are displayed on the page and their behavior. Not all tags are used to display information, there are tags that are used only for programming page behavior, for example, using JavaScript.

      Questions for self-control

      1. What is Hypertext?
      2. What is the need to use HTML?
      3. What is page encoding? Why is it used? Where can I change the encoding in the browser?
      4. What kinds of attributes are you aware of?
      5. What are tags? How are they different from attributes?
      6. What tags must an HTML page contain?

      The text of the lesson was developed jointly with M.

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

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

      All HTML elements are of five types:

      • empty elements , ,
        , , ,
        , , ,
        Used to store additional information about the page. Browsers use this information to process the page, and search engines use it to index it. In the block there may be multiple tags , since, depending on the attributes used, they carry different information. Measurement indicator in the specified range.