Text and Paragraph Formatting in HTML: Essential Tags With Examples

HTML provides dedicated elements for structuring paragraphs, formatting text and emphasizing important information. Combining semantic HTML with CSS allows developers to create accessible, readable and visually consistent web pages.

Georgios Angelis
By
Georgios Angelis
Georgios Angelis
Web Developer - IT Specialist & Digital Marketing Expert
Georgios Angelis is a Web Developer and Digital Marketing Expert based in Thessaloniki, Greece, with extensive professional experience in website development, search engine optimization (SEO), digital...
- Web Developer - IT Specialist & Digital Marketing Expert
5 Min Read

In addition to altering text size and boldness, HTML can be used to define and convey the meaning of information to browsers, as well as search engines and screen readers.

Knowing which HTML elements to use is key.

Defining Paragraphs

The element is used to define a paragraph. Usually browsers will present these as distinct paragraph boxes with space in between.

<p>This is the first paragraph.</p>

<p>This is the second paragraph.</p>

Consecutive spaces and line breaks are typically condensed to one space in HTML. However, simply including blank lines in the HTML source will not necessarily cause browsers to add extra space.

To add a line break, without beginning a new paragraph, the < br > element is used.

<p>
    25 Oxford Street<br>
    London<br>
    United Kingdom
</p>

This is suitable for, for example, addresses and poems. Do not use several

elements to add space between paragraphs – CSS margin properties should be used for this instead.

Key Text HTML Elements

There are various HTML elements that can be used to alter both the style and/or meaning of text.

HTML tagPurposeDefault appearance
<b>Draws attention to textBold
<strong>Indicates strong importanceBold
<i>Alternative voice or technical termItalic
<em>Indicates stress emphasisItalic
<u>Non-textual annotationUnderlined
<mark>Highlights relevant textHighlighted
<small>Side comments or fine printSmaller text
<del>Deleted contentDeleted
<ins>Inserted contentInserted
<sub>Subscript\(H_2O\)
<sup>Superscript\(x^2\)

Whilst the styles of and are typically the same, they differ semantically. The same is true of and .

You should utilise elements for their semantic value, in addition to (or even in preference to) their style.

Multiple Text Styling

HTML text styling elements can be combined.

<p>This is <strong><em>important information</em></strong>.</p>

<p>Previous price: <del>$100</del></p>

<p>New price: <strong>$75</strong></p>

Elements should always be closed in the opposite order to that in which they were opened. Poorly nested elements can lead to unexpected visual effects.

Using CSS To Style Paragraphs

Whilst HTML is used to describe the structure of information, CSS is used to define its style.

Below is an example of how CSS can be used to style, and add space around, paragraphs.

p {
    font-family: Arial, sans-serif;
    font-size: 18px;
    line-height: 1.6;
    color: #333333;
    text-align: left;
    margin-bottom: 20px;
}

The line-height property is used to set the space between lines of text. Margin bottom is used to add space after a paragraph.

Furthermore, specific classes can be applied to paragraphs so that they can be styled in different ways.

<p class="intro">
    Welcome to our web development tutorial.
</p>
.intro {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

This is a more versatile solution than adding style information to each paragraph.

Text Alignment

CSS allows text to be left, centre, right or fully justified. Each of these options will arrange text differently within the available space.

Left / Center / Right / Justify

CSS property: text-align: {alignment};

Generally, English text is pleasingly readable if left-aligned. Fully justified text has parallel left and right hand sides. However, this can cause inconsistent spacing between words, particularly on mobiles with limited screen width.

Maintaining Spacing and Coding

The element ensures that the exact spaces and line breaks from the HTML source code are reproduced.

To show computer coding, the element should also be used.

<pre><code>
function greet() {
    return "Hello World";
}
</code></pre>

When showing HTML source code, characters that are not permitted in HTML need to be replaced with HTML entities (for example, < and >).

Failure to do this may cause browsers to attempt to execute the shown code, as they would with standard HTML.

Do Not Use Outdated Text Styling Elements

Previously, many websites utilised HTML elements including <font>, <center>, <big> and <strike> to style text.

However, these are no longer valid in current HTML.

Instead, use CSS properties such as font-size, font-family, color, text-align and text-decoration.

By distinguishing between the structural and stylistic aspects of information, HTML source code can be simplified. It can then be more easily maintained and a uniform style can be achieved across different devices.

Share This Article
Georgios Angelis
Web Developer - IT Specialist & Digital Marketing Expert
Follow:
Georgios Angelis is a Web Developer and Digital Marketing Expert based in Thessaloniki, Greece, with extensive professional experience in website development, search engine optimization (SEO), digital advertising, e-commerce, and web technologies. He is a Google-certified professional and runs Netclick Digital, a digital marketing agency recognized as a Google Partner. His professional expertise includes Google Ads, Meta Ads, technical SEO, WordPress development, PHP programming, web analytics, marketing automation, and digital growth strategies. Combining technical development skills with data-driven marketing expertise, he helps businesses improve their online visibility, website performance, customer acquisition, and digital presence. As a contributing author at SkillOnPage, Georgios shares practical knowledge and professional insights on web development, programming, digital marketing, SEO, artificial intelligence, e-commerce, and emerging digital technologies.
Leave a Comment

Leave a Reply

Your email address will not be published. Required fields are marked *