Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore.

15 St Margarets, NY 10033
(+381) 11 123 4567



HTML Tags for Text – DZone Web Dev

HTML is full of lots of different tags for text. These tags let us display text in our HTML documents in the ways we want it to be displayed. 

Although tags are a basic feature of HTML, there is a lot to learn about them. Most tags for text are inline but there are exceptions. When an element is inline, that means by default they have this line of CSS applied to them:

What Is an Inline Element in HTML?

Inline tags for text behave differently than block elements. They do not break the flow of content, and only take up as much space as is necessary. Block elements, on the other hand, tend to take up the full width of a page.

Therefore, HTML tags for text are all inline, since they are used in writing text, and they flow with other inline elements on the page.

Are There Any Block Tags for Text?

Some tags we use for text are block elements. This mostly refers to headers and paragraphs, which usually take up an entire line or section on a page. As such, a new paragraph appears below the last paragraph, instead of next to it, as you would expect.

Now that we’ve covered the basics, Let’s look at some of the main inline tags we use for text in HTML, some of which you may not have heard of before.

The Header Tags

In HTML, we can denote headers using numbered header tags. These are all block elements. The <h1> is the biggest tag on the page, while the <h6> is the smallest and least important. In modern search engines and when following best practice, the <h1> tag usually denotes the title of the page you are on – so you typically only have one <h1>.

Here is an example of all the header tags, from most important and biggest, to least important and smallest:

<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>

The p Tag 

This tag is a block tag for text, used to denote a paragraph. A paragraph in HTML usually has some margin, to separate it from other paragraph tags. An example is shown below:

The List Tags: ul, ol and li

If we want to make a list in HTML like the example below, we use list tags:

There are two types of lists – ol, or ordered lists, and ul, or unordered lists. Essentially, ordered lists have numbers, and unordered lists have standard bullet points.

Within ol and ul lists, you have li elements, which refer to list items. All three are block elements. Two examples are shown below:

    <li>Hi there</li>
    <li>I am a list</li>
    <li>Hi there</li>
    <li>I am a list</li>

The blockquote Tag

The blockquote tag is, as the name suggests, a block element. It lets us create quotes. This is often combined with figcaption for the caption, cite for who is cited, and figure, to encapsulate everything, to create a fully-fledged quote. Here is an example of all that in action:

        I am HTML
    <figcaption>HTML, from <cite>HTML in action</cite></figcaption>

The result looks like this:


HTML, from HTML in action

The em Tag

The em tag is used to make text emphasized or italicized. Here is an example of how that looks. In code, we write it like this:

<em>An emphasised piece of text</em>

The strong Tag

The strong tag is used to make the text bold. It looks like this in code:

<strong>An emphasised piece of text</strong>

The br Tag

This element makes a line break anywhere you like. It looks like this in code:

The u Tag

This element makes text underlined. It looks like this in code:

The code Tag

This element highlights a piece of code on the page. It is styled like below:

I am some code

<code>I am some code</code>

The pre Tag

This element denotes text that shouldn’t have any line breaks. If you keep typing, this element will stop the text from breaking at any point, instead of overflowing. An example is shown in the code element below. The text keeps going, even though it reaches the end of the container:

<pre>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce fermentum mi nec ipsum feugiat, sagittis vulputate diam pretium. Praesent aliquam viverra tempor. Curabitur consectetur bibendum ultricies. Pellentesque vel efficitur sapien. Vivamus non turpis accumsan, semper quam sed, viverra diam. Mauris arcu elit, tempus eget elementum id, laoreet finibus erat. In nec diam commodo, accumsan turpis at, blandit risus. Sed eget ligula purus. Maecenas non commodo eros. Curabitur viverra felis vitae nisl hendrerit, at vestibulum erat luctus. Pellentesque consequat ipsum mi, ut aliquam enim viverra in.</pre>

The button Tag

This element lets us create a button. An example is shown below, along with the code:

<button>I am a button</button>

The s Tag

This tag represents a struck-through piece of text, like this. It can be written in code like this:

Credit: Source link

Previous Next
Test Caption
Test Description goes like this