You are on page 1of 14

4/1/24, 5:05 AM HTML Text Formatting - GeeksforGeeks

HTML Tutorial HTML Exercises HTML Tags HTML Attributes Global Attributes Event Attributes HTML Inter

HTML Text Formatting


HTML Text Formatting provides various tags for text formatting to enhance
the visual presentation of content on a webpage. You can make your text bold,
italic, etc. by using some HTML tags.

Text Formatting can be categorized into 2 techniques, i.e., the logical tag
where the tags denote the logical or semantic value of the text, and the
Physical tag, which denotes the visual appearance of the text.

Table of Content
HTML Formatting Elements
Making text Bold or Strong
Making text Italic or emphasize
Highlighting a Text
Making a text as Subscript or Superscript
Making text smaller
Striking through the text
Adding a Text
Supported Browsers

HTML Formatting Elements

Tags Descriptions

<i> Showcases italicized text.

<small> Renders text in a smaller font size.

<ins> Highlights added or inserted text.

<sub> Creates subscript text.

Emphasizes text with importance, often


<strong>
in bold.

https://www.geeksforgeeks.org/html-text-formatting/?ref=lbp 1/14
4/1/24, 5:05 AM HTML Text Formatting - GeeksforGeeks

Tags Descriptions

<b> Displays text in a bold format.

Accentuates text with a background


<mark>
highlight.

<del> Strikes through text to signify deletion.

Adds emphasis to text, commonly


<em>
styled as italic.

<sup> Formats text as superscript.

Example: This example display text in HTML strong, small, and Highlight
formatting respectively.

HTML

<!DOCTYPE html>

https://www.geeksforgeeks.org/html-text-formatting/?ref=lbp 2/14
4/1/24, 5:05 AM HTML Text Formatting - GeeksforGeeks

<html>

<head>
<title>
HTML text formatting
</title>
</head>

<body>
<h2>Welcome To GeeksforGeeks</h2>

<!--Text in Strong-->
<strong>Hello Geeks</strong>
<br>

<!--Text in small-->
<small>Hello Geeks</small>
<br>

<!--Text in Highlight-->
<mark>Hello Geeks</mark>
</body>

</html>

Output:

Formatting the text using various HTML tags

Making text Bold or Strong


We can make the text bold using the <b> tag. The tag uses both opening and
closing tags. The text that needs to be made bold must be within <b> and
</b> tag. We can also use the <strong> tag to make the text strong, with
added semantic importance. It also opens with <strong> and ends with
</strong> tag.

Example 1: The below example describes the formatting of the text to normal,
bold, & strong.

HTML

<!DOCTYPE html>

https://www.geeksforgeeks.org/html-text-formatting/?ref=lbp 3/14
4/1/24, 5:05 AM HTML Text Formatting - GeeksforGeeks

<html>

<head>
<title>HTML bold Text</title>
</head>

<body>
<!--Normal text-->
<p>Hello GeeksforGeeks</p>

<!--Text in Bold-->
<p>
<b>Hello GeeksforGeeks</b>
</p>

<!--Text in Strong-->
<p>
<strong>Hello GeeksforGeeks</strong>
</p>
</body>

</html>

Output:

Formatting the text using different tags

Making text Italic or emphasize


The <i> tag is used to italicise the text. It opens with <i> and ends with </i>
tag. The <em> tag is used to emphasize the text, with added semantic
importance. It opens with <em> and ends with </em> tag.

Example 2: The below example describes the formatting of the text to Italic or
emphasize.

HTML

<!DOCTYPE html>
<html>

<head>
<title>HTML italic formatting</title>
</head>

https://www.geeksforgeeks.org/html-text-formatting/?ref=lbp 4/14
4/1/24, 5:05 AM HTML Text Formatting - GeeksforGeeks

<body>
<!--Normal text-->
<p>Hello GeeksforGeeks</p>

<!--Text in Italics-->
<p>
<i>Hello GeeksforGeeks</i>
</p>

<!--Text in Emphasize-->
<p>
<em>Hello GeeksforGeeks</em>
</p>
</body>

</html>

Output:

Formatting the text using & tags

Highlighting a Text
It is also possible to highlight a text in HTML using the <mark> tag. It has an
opening tag <mark> and a closing tag </mark>.

Example: The below example describes the use of the <mark> tag that is used
to define the marked text.

https://www.geeksforgeeks.org/html-text-formatting/?ref=lbp 5/14
4/1/24, 5:05 AM HTML Text Formatting - GeeksforGeeks

HTML

<!DOCTYPE html>
<html>

<head>
<title>Highlight the text in HTML</title>
</head>

<body>
<!--Text in Normal-->
<p>Hello GeeksforGeeks</p>

<!--Text in Highlight-->
<p>
<mark>Hello GeeksforGeeks</mark>
</p>
</body>

</html>

Output:

Using Tag

Making a text as Subscript or Superscript


The <sup> element is used to superscript a text and the <sub> element is
used to subscript a text. They both have an opening and a closing tag.

Example: The below example describes the use of the <sup> & <sub> tags
that are used to add the superscript & subscript texts to the HTML document.

HTML

<!DOCTYPE html>
<html>

<head>
<title>Superscript and Subscript</title>
</head>

<body>
<!--Text in Normal-->

https://www.geeksforgeeks.org/html-text-formatting/?ref=lbp 6/14
4/1/24, 5:05 AM HTML Text Formatting - GeeksforGeeks

<p>Hello GeeksforGeeks</p>

<!--Text in Superscript-->
<p>Hello
<sup>GeeksforGeeks</sup>
</p>

<!--Text in Subscript-->
<p>Hello
<sub>GeeksforGeeks</sub>
</p>
</body>

</html>

Output:

Making text smaller


The <small> element is used to make the text smaller. The text that needs to
be displayed smaller should be written inside <small> and </small> tag.

Example: The below example describes the use of the <small> tag that is
used to set small font sizes.

HTML

<!DOCTYPE html>
<html>

<head>
<title>HTML <small></title>
</head>

<body>
https://www.geeksforgeeks.org/html-text-formatting/?ref=lbp 7/14
4/1/24, 5:05 AM HTML Text Formatting - GeeksforGeeks

<!--Text in Normal-->
<p>Hello GeeksforGeeks</p>

<!--Text in small-->
<p>
<small>Hello GeeksforGeeks</small>
</p>
</body>

</html>

Output:

Using Tag

Striking through the text


The <del> element is used to strike through the text marking the part as
deleted. It also has an opening and a closing tag.

Example: The below example describes the use of the <del> tag that is used
to mark a portion of text which has been deleted from the document.

HTML

<!DOCTYPE html>
<html>

<head>
<title>HTML striking </title>
</head>

<body>
<!--Text in Normal-->
<p>Hello GeeksforGeeks</p>

<!--Text in Delete-->
<p> <del>Hello GeeksforGeeks</del> </p>
</body>

</html>

Output:
https://www.geeksforgeeks.org/html-text-formatting/?ref=lbp 8/14
4/1/24, 5:05 AM HTML Text Formatting - GeeksforGeeks

Using Tag

Adding a Text
The <ins> element is used to underline a text marking the part as inserted or
added. It also has an opening and a closing tag.

Example: This example describes the use of the <ins> tag to used to specify a
block of inserted text.

HTML

<!DOCTYPE html>
<html>

<head>
<title>Inserting the text in HTML</title>
</head>

<body>
<!--Text in Normal-->
<p>Hello GeeksforGeeks</p>

<!--Text in Insert-->
<p>
<ins>Hello GeeksforGeeks</ins>
</p>
</body>

</html>

Output:

Using tag

Supported Browsers
Google Chrome 1
Microsoft Edge 12
Firefox 1

https://www.geeksforgeeks.org/html-text-formatting/?ref=lbp 9/14
4/1/24, 5:05 AM HTML Text Formatting - GeeksforGeeks

Opera 12.1
Safari 1

“This course was packed with amazing and well-organized content! The
project-based approach of this course made it even better to understand
concepts faster. Also the instructor in the live classes is really good and
knowledgeable.”- Tejas | Deutsche Bank

With our revamped Full Stack Development Program: master Node.js and
React that enables you to create dynamic web applications.

So get ready for salary hike only with our Full Stack Development Course.

Last Updated : 15 Jan, 2024 127

Previous Next

HTML Paragraphs HTML Quotations

Share your thoughts in the comments Add Your Comment

Similar Reads
HTML Text Formatting Elements CSS Text Formatting

JavaScript | Text Formatting Which property is used to control the


flow and formatting of text ?

What are the various formatting tags How to select all text in HTML text input
available in HTML ? when clicked using JavaScript?

How to create long shadow of text Text Animation with changing the color
without using text-shadow in HTML and of the text using HTML and CSS
CSS ?

https://www.geeksforgeeks.org/html-text-formatting/?ref=lbp 10/14
4/1/24, 5:05 AM HTML Text Formatting - GeeksforGeeks

Primer CSS General Formatting Role of ViewPort in Visual Formatting


Model

C Chinmoy …

Article Tags : HTML-Basics , HTML , Web Technologies

A-143, 9th Floor, Sovereign Corporate


Tower, Sector-136, Noida, Uttar Pradesh -
201305

Company Explore
About Us Hack-A-Thons
Legal GfG Weekly Contest
Careers DSA in JAVA/C++
In Media Master System Design
Contact Us Master CP
Advertise with us GeeksforGeeks Videos
GFG Corporate Solution Geeks Community
Placement Training Program

https://www.geeksforgeeks.org/html-text-formatting/?ref=lbp 11/14
4/1/24, 5:05 AM HTML Text Formatting - GeeksforGeeks

Languages DSA
Python Data Structures
Java Algorithms
C++ DSA for Beginners
PHP Basic DSA Problems
GoLang DSA Roadmap
SQL Top 100 DSA Interview Problems
R Language DSA Roadmap by Sandeep Jain
Android Tutorial All Cheat Sheets
Tutorials Archive

Data Science & ML HTML & CSS


Data Science With Python HTML
Data Science For Beginner CSS
Machine Learning Tutorial Web Templates
ML Maths CSS Frameworks
Data Visualisation Tutorial Bootstrap
Pandas Tutorial Tailwind CSS
NumPy Tutorial SASS
NLP Tutorial LESS
Deep Learning Tutorial Web Design
Django Tutorial

Python Tutorial Computer Science


Python Programming Examples Operating Systems
Python Projects Computer Network
Python Tkinter Database Management System
Web Scraping Software Engineering
OpenCV Tutorial Digital Logic Design
Python Interview Question Engineering Maths

DevOps Competitive Programming


Git Top DS or Algo for CP
AWS Top 50 Tree
Docker Top 50 Graph
Kubernetes Top 50 Array
Azure Top 50 String
GCP Top 50 DP
https://www.geeksforgeeks.org/html-text-formatting/?ref=lbp 12/14
4/1/24, 5:05 AM HTML Text Formatting - GeeksforGeeks

DevOps Roadmap Top 15 Websites for CP

System Design JavaScript


High Level Design JavaScript Examples
Low Level Design TypeScript
UML Diagrams ReactJS
Interview Guide NextJS
Design Patterns AngularJS
OOAD NodeJS
System Design Bootcamp Lodash
Interview Questions Web Browser

Preparation Corner School Subjects


Company-Wise Recruitment Process Mathematics
Resume Templates Physics
Aptitude Preparation Chemistry
Puzzles Biology
Company-Wise Preparation Social Science
English Grammar
World GK

Management & Finance Free Online Tools


Management Typing Test
HR Management Image Editor
Finance Code Formatters
Income Tax Code Converters
Organisational Behaviour Currency Converter
Marketing Random Number Generator
Random Password Generator

More Tutorials GeeksforGeeks Videos


Software Development DSA
Software Testing Python
Product Management Java
SAP C++
SEO - Search Engine Optimization Data Science
Linux CS Subjects
Excel

https://www.geeksforgeeks.org/html-text-formatting/?ref=lbp 13/14
4/1/24, 5:05 AM HTML Text Formatting - GeeksforGeeks

@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved

https://www.geeksforgeeks.org/html-text-formatting/?ref=lbp 14/14

You might also like