How To Add Text In HTML?

How do I insert text into an HTML page? There are special HTML tags for text.

There are six levels of headings in HTML. They are added with the help of tags h1 – h6. In this case, h1 is the first level header, it is the largest.

Example of creating headers:

<h1> First level header </h1>
<h2> Second level header </h2>
<h3> Third level header </h3>
<h4> Fourth level header </h4>
<h5> Fifth level header </h5>
<h6> Sixth level header </h6>

The headers are independent of each other. You can add any level of header wherever you want.

Newbies sometimes cannot understand the question – how many first-level headers can be on the page. More than once I encountered on the Internet on this subject incomplete and unreliable information. Therefore, I decided to consider this issue in detail.

On the number of tags h1 has no effect on the page. You can add them as much as you like. But search engines have a negative attitude to the fact that the page is more than one heading of the first level. Therefore, if you are going to promote your site in search engines, then each page should be only one heading of the first level. Conclusion: it is better to get used to not putting more than one h1 tag per page. After all, in HTML there are six levels of headings. In any page layout is enough to allocate the h1 tag only for one header.


The p tag creates a paragraph of text. It has top and bottom indents to separate one paragraph from another. It also has an option to indent the first line. This is all controlled by CSS.

<p>A paragraph of text</p>

Tag br

The br tag is not really a text tag. It performs a line feed. If it is inside the text, the following text goes on a new line. And if it is between blocks, it adds an empty line.

Example of a line feed:

<p>Start text<br>new line</p>

Span tag

The span tag is a lowercase tag for inserting text. It is usually used when you want to highlight part of the text in a certain way.
For example, let’s select a part of the text in red.

<p>The beginning of the text <span style="color: red">red text</span>
text continuation</p>

The desired part of the text is inside the span tag. To make it red, the tag has a style attribute that sets the styles. Since working with styles is described in the CSS tutorial, I won’t explain how this attribute works here. Just add it to the tag as written in the example.

Pre tag

The pre tag is used for special types of text where it is important to preserve formatting. The text inside this tag is displayed on the page exactly as it looks in the page code. It preserves all spaces and line breaks. The text is displayed in a monospaced font, but this can be changed with styles.

<pre>text text after spaces
next line
next line</pre>

Highlighting text

There are tags in HTML to highlight text. The b and strong tags create a bold typeface. Although these tags have some differences, they usually look the same on the page. The i and em tags highlight text in italics. There is a u tag that makes the text underlined, but its use is undesirable.

An example of text highlighting:

<b>Bold font</b>
<strong>Bold font</strong>
<i>Cursive font</i>
<em>Cursive font</em>.

Text can be highlighted with styles. It’s up to you to decide whether you want the text to be highlighted with tags or styles.

Other tags

We have considered special HTML tags for text. But text can contain many other tags which add content to a page. You can even put the text without any tags, it will be shown anyway. But in practice nobody does this because you cannot control the text outside of tags. So all the text, of course, should be inside the tags. And when you learn CSS, you will be able to define the appearance of text.

Recommended Articles