• Tag new paragraph. Basic tags (tags) html. Rules and order of writing tags

    Tags defining paragraph, space, HTML block and paragraph

    Let's look at it in detail HTML blocks and paragraphs as elements of a web page.

    • HTML paragraph defined by tags.
    • HTML paragraphs usually contain text, formatting tags, and images.
    • HTML paragraph cannot contain block elements such as headers

      -

      , block
      and other paragraphs.
    • HTML block defined by tags
      .
    • HTML block can contain any elements of a web page, in any quantity.
    • HTML blocks Great for web pages and easy to manipulate.

    Consider the code below:

    Result:

    We can see that HTML paragraphs have vertical indentations - this is a feature of tags. HTML blocks

    such spaces are not created because they do not carry any load, but are simply containers.

    Tags cannot contain other or

    . Linear elements can be placed inside, such as or, for example, tags responsible for text formatting.

    Tags and , in principle, are the same thing, but the W3C consortium recommends using small letters. In the new version of HTML, as in modern XHTML, the use of capital letters when writing tags is prohibited.

    Block

    can contain as many as you like
    and other elements HTML document. It is ideal for layout, but more on that later - in the CSS tutorial lessons.

    HTML space from special characters table

    HTML space allows you to increase the distance between words and characters.

    As for the spaces between words, no matter how many there are in Notepad, that is, in the source code, only one will be displayed on the web page. If you need to increase the distance, use the space character from the symbol table. You may ask: Why are these encoded meanings of ordinary characters needed? - I will answer: They are needed to display, for example, such brackets< >. In other words, to display tags on the screen, in my editor I write: . Tags , as we remember, convert the text to monospace (typewritten).

    Ways to display an HTML paragraph

    Examples of paragraph output.

    As a rule, blocks of text are separated by paragraphs (paragraphs). By default, there is a small vertical space between paragraphs, called a space. The syntax for creating paragraphs is as follows.

    Paragraph 1

    Paragraph 2

    Each paragraph begins with a tag

    And ends with an optional closing tag

    .

    In any book, the first line indentation, also called the “red line,” is used to highlight the next paragraph. This allows the reader to easily look for a new line and thus increases the readability of the text. On a web page, this technique is usually not used, but padding is used to separate paragraphs.

    Example 7.1 shows the use of paragraphs to create indents between lines.

    Example 7.1. Using Paragraphs

    Using paragraphs

    In some places it’s still February, in others it’s already April.

    Time passes, eternal counting: year after year, century after century...

    In everything - his unhurried pace, his pitch-black running.

    There are twenty-five weeks of joy and sorrow in a year.

    I'm twenty-five weeks into February, and twenty-five weeks into April.

    For twenty-five weeks, centuries pass into the fog.

    My sonorous farce is flying somewhere towards the clouds.

    M. Shcherbakov

    The result of this example is shown in Fig. 7.1.

    Rice. 7.1. Indentation on a web page when using paragraphs

    As can be seen from the figure, when using the tag

    There are too many spaces between paragraphs. You can get rid of them if you add a tag at line breaks:
    . Unlike a paragraph, a line break tag
    does not create additional vertical spaces between lines and can be used in almost any text.

    Thus, the text of example 7.1, taking into account line breaks, will be transformed as follows (example 7.2).

    Example 7.2. Tag

    Hyphenations in the text

    Almond trees are blooming in some gardens, while snowstorms are blowing in others.
    In some places it’s still February, in others it’s already April.
    Time passes, eternal counting: year after year, century after century...
    In everything - his unhurried pace, his pitch-black running.
    There are twenty-five weeks of joy and sorrow in a year.
    I'm twenty-five weeks into February, and twenty-five weeks into April.
    For twenty-five weeks, centuries pass into the fog.
    My sonorous farce is flying somewhere towards the clouds.

    M. Shcherbakov

    The result of the example is shown in Fig. 7.2. It can be seen that the distance between the lines of text has decreased and it has acquired a more compact appearance.

    In the last lesson about the document, we looked at the six levels of headings that an html page can include, and learned the rules for using the “h1-h6” tag. In this tutorial we will look at, paragraph tag, which will give our text the correct appearance on the page.

    In the next post I will tell you how to make your website even more beautiful (so you don't miss it). We will learn how to create a stylish background. I will split this pic into two parts, in the first part we will work with Photoshop, and in the second we will play with cascading style sheets.

    Paragraph tag or the paragraph tag “p” allows you to create a paragraph from text on a web document page. If you do not use the “p” tag, but simply enter text without design, you will end up with unstructured, ugly text.

    By using the paragraph tag, the text becomes more or less readable, which makes the page more attractive. Let's look at a document that doesn't use the paragraph tag:

    XHTML

    HTML page title Today, I woke up early as always. The morning sun was shining through the curtains of my window. Stretching, I went to the kitchen. I made myself some green tea, added two spoons of sugar and sat down in a soft chair in front of the kitchen window. It was autumn outside. I like this time of year because I think autumn is the most romantic time of the year. After finishing my tea, I took my mobile phone and called my beloved to wish her good morning. As I thought, she was still sleeping. We had a nice chat and agreed to meet this afternoon while the sun was shining and it was warm outside. Time flew by. And now we are together, having lunch at a local cafe: eating, chatting, flirting with each other. We feel good together. I love my girlfriend and that applies to me too. We are thinking about starting a family...

    <span>HTML page title</span>

    Today, I woke up early as always. The morning sun was breaking through

    the curtains of my window. Stretching, I went to the kitchen. I made myself some green tea,

    put two spoons of sugar and sat down in a soft chair in front of the kitchen window. Outside

    it was autumn. I like this time of year because I believe that autumn is the most...

    romantic time of year. After I finished my tea, I took my mobile phone and called

    to your beloved, wish her good morning. As I thought, she was still sleeping. We're cute

    talked and agreed to meet this afternoon while the sun was shining and

    It's warm outside. Time flew by. And now we are together, having lunch at a local

    cafe: we eat, chat, flirt with each other. We feel good together. I love mine

    the girl and me too. We are thinking about starting a family...

    Here's what we ended up with:

    The text is poorly formatted. Everything is lumped together, without any structure. The following example shows the use of the paragraph tag "p". This tag is a paired, block tag, but inside itself can only contain line tags. Block tags inside a "p" tag are not allowed, including the "p" tag itself:

    XHTML

    HTML page title

    Paragraph one. To make the text on your pages readable, use the “p” paragraph tag. This text is surrounded by a paired “p” tag, which allows the browser to recognize the text as a paragraph.

    Paragraph two. This is the second paragraph, coming after the first. This paragraph will be indented from the first paragraph. An example of using paragraphs can be seen in the figure below.

    <span>HTML page title</span>

    Paragraph one. To make the text on your pages readable

    The paragraph tag "p" is used. This text is framed in a paired “p” tag, which allows

    The browser recognizes the text as a paragraph.

    Paragraph two. This is the second paragraph, coming after the first. This paragraph will have

    indentation from the first paragraph. You can see an example of using paragraphs at

    picture below.

    This is what we got when we started using a paragraph:

    Two components of the page appeared - two paragraphs separated by an indent. And so troubles with each new paragraph. For our first example, where the paragraph tag is not used, we can apply the following formatting using the "p" tag:

    XHTML

    HTML page title

    Sunny morning

    Today, I woke up early as always. The morning sun was shining through the curtains of my window. Stretching, I went to the kitchen. I made myself some green tea, added two spoons of sugar and sat down in a soft chair in front of the kitchen window. It was autumn outside.

    I like this time of year because I think autumn is the most romantic time of the year. After finishing my tea, I took my mobile phone and called my beloved to wish her good morning. As I thought, she was still sleeping.

    We had a nice chat and agreed to meet this afternoon while the sun was shining and it was warm outside. Time flew by. And now we are together, having lunch at a local cafe: eating, chatting, flirting with each other. We feel good together. I love my girlfriend and that applies to me too. We are thinking about starting a family...

    <span>HTML page title</span>

    Sunny morning

    Today, I woke up early as always. The morning sun was shining through the curtains of my window. Stretching, I went to the kitchen. I made myself some green tea, added two spoons of sugar and sat down in a soft chair in front of the kitchen window. It was autumn outside.

    I like this time of year because I think autumn is the most romantic time of the year. After finishing my tea, I took my mobile phone and called my beloved to wish her good morning. As I thought, she was still sleeping.

    We had a nice chat and agreed to meet this afternoon while the sun was shining and it was warm outside. Time flew by. And now we are together, having lunch at a local cafe: eating, chatting, flirting with each other. We feel good together. I love my girlfriend and that applies to me too. We are thinking about starting a family...

    As you already noticed, I added a title to the text. I used only three paragraphs, and this version, as always, turned out to be better than the one before. Now we have semantic divisions of text (indents between paragraphs). In general, it would be correct to say not “paragraph”, but “paragraph”, since the tag “p” translated from English means “paragraph”. Next I will say paragraph, so don't get confused.

    This is approximately what you should get after using it paragraph tag:

    The paragraph tag, like all other html tags, has attributes. Now we will look at the most important attributes of the “p” tag.

    • id – defines a universal identifier used when writing properties in a cascading style sheet file (usually style.css). The identifier name is used only once within the same document
    • class – the same as id, but can be used several times within the same document
    • title – a tooltip displayed in the browser window when you hover the mouse over the text of a paragraph
    • style – defines a set of properties for cascading style sheets
    • align – determines the alignment of the paragraph text relative to the browser window (left – left , right – right , centered – center , justified – justify)
    • etc. (JavaScript elements)

    Example of using attributes:

    XHTML

    HTML page title

    If you hover your mouse over this text, a hint will appear!!!

    This paragraph is left aligned

    This paragraph is right aligned

    This paragraph is center aligned

    This paragraph has a universal identifier that refers to properties written in the CSS file and can only be used once on the page

    This paragraph has a MAIN-P class, can be assigned several times on a page, unlike the ID identifier

    This paragraph is all underlined because... uses cascading styles assigned directly to this paragraph using the STYLE tag attribute. In the value of the STYLE attribute, I specified that the entire paragraph should be underlined: UNDERLINE

    s

    <span>HTML page title</span>

    This paragraph is all underlined because... uses cascading styles assigned directly to this paragraph using the STYLE tag attribute. In the value of the STYLE attribute, I specified that the entire paragraph should be underlined: UNDERLINE

    s

    Paragraphs and headings

    The main way to present information on the Internet is text; it is text information that most people look for, and it is text words and phrases that are used by special search engines to carry out this search. Therefore, whether the visitor will linger on the site or go looking for a more convenient source of information will largely depend on how well and conveniently the text on the pages is structured. After all, you will agree that reading a continuous text is much more difficult than reading one divided into paragraphs and thematic subsections. In HTML, several tags are responsible for this text structuring, and we will talk about them in this lesson.

    Tag

    Or we break the page into paragraphs (paragraphs)

    If you remember, then with the tag

    You have already met in this textbook, well, now it’s time to study it completely. So the tag

    Responsible for creating paragraphs in an HTML page and is block element. I hope that you have already remembered what block level tags are. Yes, but in addition to the fact that it creates line breaks in front of and after itself to the beginning, it also sets small margins (external indents) of empty space above and below itself, due to which the text is visually divided into paragraphs. The height of these fields is equal to one empty line.

    Now the most important thing is the tag

    Can only contain row-level (inline) elements and nothing else. Therefore, for example, it cannot contain another paragraph, since it itself

    Is a block element. Well, we will return to this more than once. By the way, any text without tags is also considered an inline element.

    Example of paragraphs in HTML

    Paragraphs in HTML

    First paragraph.

    Second paragraph.

    Result in browser

    First paragraph.

    Second paragraph.

    In general, the closing tag

    It is not necessary to set it - as soon as the browser encounters the next paragraph, it will automatically close the previous one. But, as I already said, it is better to close all optional tags.

    At the tag

    There is one optional attribute, align , which sets the position of the text within the block. that is, you can have each line of a paragraph centered on the page or pressed to the right side rather than to the left as usual. The only problem is that the align attribute is not in the strict version of HTML and, perhaps, modern browsers will no longer support it in the near future. So what should we do? And we will do the following: in one of the upcoming lessons I will show you a universal method with which you can change the position of content not only inside paragraphs, but also inside any block elements of an HTML page (headings, tables, lists, etc.). But the main thing is that all browsers understand it and will understand it.

    Tags

    -

    or HTML page headers

    Headings play a very important role in HTML; using them, you can divide the text of a page into logical parts, emphasizing the importance of each, which allows visitors to quickly find the information they need. In addition, search engines (Yandex, Google, etc.) give more “weight” to the text in headings. There are six types, where

    the most important heading (first level, top), and

    least significant (sixth level, lower). For example,

    could be the page title,

    - its sections,

    - subsections, etc.

    Heading tags are block elements and, like paragraphs, can only contain line-level tags and text. Browsers make heading text bold, different sizes (depending on the tag) and add white space margins at the top and bottom, again like paragraphs.

    Syntax for writing headers in HTML

    First level header

    Second level heading

    Third level heading

    Fourth level heading

    Level 5 heading
    Level six heading

    Title tags have two optional attributes - the familiar old-fashioned align and the title attribute, which displays a tooltip when you hover over the title. As with paragraphs, we won't use align , but will learn another way soon.

    Example of using headers in HTML

    Headings in HTML

    First level header

    Paragraph.

    Second level heading

    Paragraph.

    Paragraph.

    Result in browser

    First level header

    Paragraph.

    Second level heading

    Paragraph.

    Paragraph.

    Homework.

    In this task you will need to create a page simulating a small article, write any text you like. You can immediately see the result of the example so that you have an idea of ​​what needs to be done.

    1. Open the page from the previous lesson in an HTML editor.
    2. Using Headings

      ,

      And

      create the title of the article, its two sections and three subsections in the second section.

    3. Make sure that when you hover your mouse over the title of an article, the corresponding inscription is displayed.
    4. Write one paragraph for each section and subsection.

    – in the process of creating a website, we have to work a lot with text blocks, or text phrases. One day, I needed to add a text phrase in such a way that before this text phrase there is some indent text from edge html block in which this text was added.

    So, the first method is the most natural and simple. To indent the text, add an html space code before the text - You can add an html space code in any html editor.

    Here is an example of working code for setting indentation for text using the space code:

    HTML left text indentation, use space code


    In this example, before the text we have selected, the space code is  added four times, as a result, we get the indent we need.

    We know that the space code is processed by any browser. Therefore, by adding the required number of spaces before the text, you can get the required indentation for the text.

    This method is good because it is guaranteed to be processed by any browser.

    But this method has a significant drawback. In order to indent the text long enough in the html code, you will have to add a large number of space characters before the text, which may not look beautiful, cumbersome and unprofessional.

    One solution to this problem is the following method of setting the indentation.

    HTML text indentation, method two - this method is based on the properties of the blockquote tag. This tag sets an indent of approximately 40 pixels on the left and right for the text placed in it. In addition, the indentation is specified at the top and bottom. An example of html code for using this method is given below:

    on the left, use the tag blockquote

    As you can see, this method of setting indentation for text is very easy to use, but this method also has a significant drawback. The indentation that the tag sets blockquote is fixed and is always equal to the same value – 40px.

    To correct the situation, and when adding html indentation and for text to be able to set any value, we will use the third method.

    HTML text indentation, method three.

    Here we will use the text-indent property of CSS Cascading Style Sheets.

    If we open the CSS reference book, on the page with a description of the properties of text-indent, we will see that using text-indent, we can set the indentation value of the first line or first paragraph, or any block of text.

    We are considering an example with a short text block, so the text-indent properties are quite suitable for our case.

    Below is the html code that indents text using text-indent. The example shows that by setting text-indent to different argument values, we can change the amount of text indentation:

    HTMLindentationtext, CSS style works - text-indent

    In my opinion, this method of setting an indent for text is the most optimal, but, nevertheless, let’s consider another way to set an indent, using images.

    HTML text indentation, fourth method - here we will use an image to set the indentation.

    As a working example, let’s immediately look at the html code that demonstrates how this method works:

    on the left, use the image

    From the above example it is clearly seen that by changing the width of the image, we can change the position of the text, that is, set the desired indent for the text.

    As an image, you can use an image whose width and height are equal to one pixel. To prevent the image we are using from being visible on the page, we will set its color exactly the same as the background of the site page.

    In my opinion, the above methods for setting indents for text are quite enough to organize the indentation you need in any situation when adding content to the page of your sites.