Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • HTML Tutorial
  • HTML Exercises
  • HTML Tags
  • HTML Attributes
  • Global Attributes
  • Event Attributes
  • HTML Interview Questions
  • HTML DOM
  • DOM Audio/Video
  • HTML 5
  • HTML Examples
  • Color Picker
  • A to Z Guide
  • HTML Formatter
Open In App
Next Article:
HTML Quotations
Next article icon

HTML Text Formatting

Last Updated : 17 Oct, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

HTML text formatting refers to the use of specific HTML tags to modify the appearance and structure of text on a webpage. It allows you to style text in different ways, such as making it bold, italic, underlined, highlighted, or struck-through.

Table of Content

  • Categories of HTML Text Formatting
    • Logical Tags
    • Physical Tags
  • HTML Formatting Elements
  • Examples of HTML Text Formatting
    • Basic Text Formatting
    • Combining Logical and Physical Tags

Categories of HTML Text Formatting

HTML text formatting can be divided into two main categories: Logical Tags and Physical Tags.

1. Logical Tags

Logical tags convey the meaning or importance of the text without necessarily altering its visual appearance. These tags help browsers, search engines, and assistive technologies understand the purpose of the text.

  • <em>: Emphasizes text, typically rendered in italics. It implies that the text carries special importance or requires emphasis.
  • <strong>: Marks text as important, often displayed in bold. It implies the content is of strong importance.

2. Physical Tags

Physical tags directly affect how text looks on the webpage by changing the font, size, or style.

  • <b>: Displays text in bold without implying importance.
  • <i>: Italicizes text without any implied emphasis.

Here’s a list of commonly used HTML text formatting tags and their description:

TagsDescription
<i>Showcases italicized text.
<small>Renders text in a smaller font size.
<ins>Highlights added or inserted text.
<sub>Creates subscript text.
<strong>Emphasizes text with importance, often in bold.
<b>Displays text in a bold format.
<mark>Accentuates text with a background highlight.
<del>Strikes through text to signify deletion.
<em>Adds emphasis to text, commonly styled as italic.
<sup>Formats text as superscript.

HTML Formatting Elements

1. <i> – Italicizes text

Use the <i> tag to display text in italics without implying emphasis.

<i>This is italic text.</i>

2. <small> – Reduces the font size of the text

The <small> tag renders text in a smaller font than the surrounding text.

<small>This text is smaller than the rest.</small>

3. <ins> – Highlights inserted text

The <ins> tag marks text as newly added or inserted, often displayed with an underline.

<ins>This is inserted text.</ins>

4. <sub> – Displays subscript text

Use the <sub> tag for subscripted text, often used in chemical formulas or footnotes.

H<sub>2</sub>O

5. <strong> – Emphasizes important text, often rendered in bold

The <strong> tag is semantically meaningful and indicates that the text is of high importance.

<strong>This text is bold and important.</strong>

6. <b> – Makes text bold

The <b> tag visually makes the text bold but does not imply any special significance.

<b>This is bold text.</b>

7. <mark> – Highlights text with a background color

The <mark> tag highlights text with a background color, similar to using a highlighter on paper.

<mark>This text is highlighted.</mark>

8. <del> – Strikes through text

The <del> tag is used to show that text has been deleted or is no longer relevant.

<del>This text is crossed out.</del>

9. <em> – Emphasizes text, typically italicized

The <em> tag is used for emphasized text and is usually rendered in italics to highlight importance.

<em>This text is emphasized.</em>

10. <sup> – Displays superscript text

Use the <sup> tag to show superscripted text, commonly used in exponents or footnotes.

E = mc<sup>2</sup>

Examples of HTML Text Formatting

Example 1: Basic Text Formatting

In this example we demonstrates various text formatting tags: <strong> for important and bold text, <em> for emphasized and italic text, <b> for bold text, <i> for italic text, and <mark> for highlighted text.

HTML
<!DOCTYPE html> <html lang="en">  <head>     <meta charset="UTF-8">     <title>Text Formatting Example</title> </head>  <body>     <p>         <strong>Strong:</strong>          This text is important and bold.     </p>     <p>         <em>Emphasized:</em>          This text is emphasized and italic.     </p>     <p>         <b>Bold:</b>          This text is bold.     </p>     <p>         <i>Italic:</i>          This text is italic.     </p>     <p>         <mark>Marked:</mark>          This text is highlighted.     </p> </body>  </html> 

Output:

text-formatting

HTML Text Formatting Example Output

Example 2: Combining Logical and Physical Tags

This example shows how logical and physical tags can be combined for enhanced text formatting:

HTML
<!DOCTYPE html> <html lang="en">  <head>     <meta charset="UTF-8">     <title>Advanced Text Formatting</title> </head>  <body>     <p>This is a          <strong><em>very important</em></strong> message.     </p>     <p>The chemical formula of water is H         <sub>2</sub>O.     </p>     <p>         <del>Deleted text</del> and          <ins>inserted text</ins>          are shown here.     </p>     <p><small>Smaller text</small>          can be used for disclaimers.     </p>     <p>E = mc<sup>2</sup></p> </body>  </html> 

Output:

basic-html-text-formatting

Combining Logical and Physical Tags



Next Article
HTML Quotations
author
chinmoy lenka
Improve
Article Tags :
  • HTML
  • Web Technologies
  • HTML-Basics
  • Web technologies-HTML and XML

Similar Reads

  • HTML Tutorial
    HTML stands for HyperText Markup Language. It is the standard language used to create and structure content on the web. It tells the web browser how to display text, links, images, and other forms of multimedia on a webpage. HTML sets up the basic structure of a website, and then CSS and JavaScript
    10 min read
  • HTML Introduction
    HTML stands for HyperText Markup Language. It is the standard language used to create and structure content on the web. It defines the structure of a webpage by using a series of elements, tags, and attributes to organize text, images, links, and other multimedia elements. HTML is a markup language,
    7 min read
  • HTML Editors
    An HTML Editor is a software application designed to help users create and modify HTML code. It often includes features like syntax highlighting, tag completion, and error detection, which facilitate the coding process. There are two main types of HTML editors: Text-Based Editors - Allow direct codi
    5 min read
  • HTML Basics
    HTML (HyperText Markup Language) is the standard markup language for creating and structuring web pages. It defines the structure of a webpage using elements and tags.HTML is responsible for displaying text, images, and other content.It serves as the foundation for building websites and web applicat
    6 min read
  • HTML Comments
    HTML comments are used to add notes or explanations in the HTML code that are not displayed by the browser. They are useful for documenting the code, making it easier to understand and maintain.To add a comment, use the syntax <!-- your comment here -->. [GFGTABS] HTML <!-- This is a commen
    4 min read
  • HTML Elements
    An HTML Element consists of a start tag, content, and an end tag, which together define the element's structure and functionality. Elements are the basic building blocks of a webpage and can represent different types of content, such as text, links, images, or headings. For example, the <p> el
    5 min read
  • HTML Attributes
    HTML Attributes are special words used within the opening tag of an HTML element. They provide additional information about HTML elements. HTML attributes are used to configure and adjust the element's behavior, appearance, or functionality in a variety of ways. Each attribute has a name and a value
    9 min read
  • HTML Headings
    HTML headings are used to define the titles and subtitles of sections on a webpage. They help organize the content and create a structure that is easy to navigate. Proper use of headings enhances readability by organizing content into clear sections.Search engines utilize headings to understand page
    4 min read
  • HTML Paragraphs
    A paragraph in HTML is simply a block of text enclosed within the <p> tag. The <p> tag helps divide content into manageable, readable sections. It’s the go-to element for wrapping text in a web page that is meant to be displayed as a distinct paragraph. Syntax: <p> Content</p
    5 min read
  • HTML Text Formatting
    HTML text formatting refers to the use of specific HTML tags to modify the appearance and structure of text on a webpage. It allows you to style text in different ways, such as making it bold, italic, underlined, highlighted, or struck-through. Table of Content Categories of HTML Text FormattingLogi
    4 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences