* Working with text in HTML :
Working with text in HTML involves using various HTML elements and attributes to format and structure the content on a webpage. Here are some of the key elements and techniques for working with text in HTML:
# Basic Text Elements :
Paragraphs (
<p>
)- Used to define a block of text.
<p>This is a paragraph.</p>
Headings (
<h1>
to<h6>
)- Used to define headings, with
<h1>
being the highest level and<h6>
the lowest.
<h1>This is an H1 heading</h1> <h2>This is an H2 heading</h2>
- Used to define headings, with
Line Breaks (
<br>
)- Used to insert a line break.
This is the first line.<br> This is the second line.
Horizontal Rules (
<hr>
)- Used to insert a horizontal line (often used to separate content).
<hr>
# Text Formatting Elements :
Bold (
<b>
) and Strong (<strong>
)<b>
makes the text bold without implying any extra importance.<strong>
indicates that the text is of strong importance and makes it bold.
<b>This text is bold.</b> <strong>This text is strongly emphasized.</strong>
Italic (
<i>
) and Emphasis (<em>
)<i>
makes the text italic without implying any extra importance.<em>
indicates emphasized text and makes it italic.
<i>This text is italic.</i> <em>This text is emphasized.</em>
Underlined (
<u>
)- Used to underline text.
<u>This text is underlined.</u>
Strikethrough (
<s>
)- Used to display text with a strikethrough.
<s>This text is struck through.</s>
Superscript (
<sup>
) and Subscript (<sub>
)<sup>
raises the text, and<sub>
lowers the text.
H<sub>2</sub>O (Water) E = mc<sup>2</sup>
# Lists :
Ordered List (
<ol>
)- Used to create a numbered list.
<ol> <li>First item</li> <li>Second item</li> <li>Third item</li> </ol>
Unordered List (
<ul>
)- Used to create a bulleted list.
<ul> <li>First item</li> <li>Second item</li> <li>Third item</li> </ul>
Definition List (
<dl>
)- Used for a list of terms and descriptions.
<dl> <dt>Term 1</dt> <dd>Description for term 1</dd> <dt>Term 2</dt> <dd>Description for term 2</dd> </dl>
Hyperlinks (<a>
)
- Used to create links to other pages or parts of the same page.
<a href="https://www.example.com">Visit Example</a>
# Special Characters :
- To display special characters, use HTML entities.
& (for &) < (for <) > (for >) " (for ") ' (for ')
# Blockquote and Cite :
Blockquote (
<blockquote>
)- Used for quoting a large section of text from another source.
<blockquote> "This is a blockquote from another source." </blockquote>
Cite (
<cite>
)- Used to reference the title of a work.
<cite>The Great Gatsby</cite>
Text Alignment
- Use the
style
attribute or CSS for text alignment.<p style="text-align: center;">This is centered text.</p>
Using CSS for Advanced Styling
For more advanced text styling, use CSS, Here’s a simple example:
* OUTPUT :
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Text Formatting Example</title>
- </head>
- <body>
- <h1>Text Formatting in HTML</h1>
- <h2>Basic Text Elements</h2>
- <p>This is a paragraph.</p>
- <p>This is another paragraph with a <br> line break.</p>
- <h2>Headings</h2>
- <h1>Heading 1</h1>
- <h2>Heading 2</h2>
- <h3>Heading 3</h3>
- <h4>Heading 4</h4>
- <h5>Heading 5</h5>
- <h6>Heading 6</h6>
- <h2>Text Formatting Elements</h2>
- <p><b>This text is bold.</b></p>
- <p><strong>This text is strongly emphasized.</strong></p>
- <p><i>This text is italic.</i></p>
- <p><em>This text is emphasized.</em></p>
- <p><u>This text is underlined.</u></p>
- <p><s>This text is struck through.</s></p>
- <p>Water is represented as H<sub>2</sub>O.</p>
- <p>Einstein's famous equation: E = mc<sup>2</sup></p>
- <h2>Lists</h2>
- <h3>Ordered List</h3>
- <ol>
- <li>First item</li>
- <li>Second item</li>
- <li>Third item</li>
- </ol>
- <h3>Unordered List</h3>
- <ul>
- <li>First item</li>
- <li>Second item</li>
- <li>Third item</li>
- </ul>
- <h3>Definition List</h3>
- <dl>
- <dt>HTML</dt>
- <dd>HyperText Markup Language</dd>
- <dt>CSS</dt>
- <dd>Cascading Style Sheets</dd>
- </dl>
- <h2>Hyperlinks</h2>
- <p>Visit <a href="https://www.example.com">Example.com</a> for more information.</p>
- <h2>Special Characters</h2>
- <p>& (Ampersand)</p>
- <p>< (Less than)</p>
- <p>> (Greater than)</p>
- <p>" (Double quote)</p>
- <p>' (Single quote)</p>
- <h2>Blockquote and Cite</h2>
- <blockquote>
- "This is a blockquote from another source."
- </blockquote>
- <p><cite>The Great Gatsby</cite> by F. Scott Fitzgerald</p>
- <h2>Text Alignment</h2>
- <p style="text-align: center;">This text is centered.</p>
- <p style="text-align: right;">This text is right-aligned.</p>
- </body>
- </html>
Text Formatting in HTML
Basic Text Elements
This is a paragraph.
This is another paragraph with a
line break.
Headings
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Text Formatting Elements
This text is bold.
This text is strongly emphasized.
This text is italic.
This text is emphasized.
This text is underlined.
This text is struck through.
Water is represented as H2O.
Einstein's famous equation: E = mc2
Lists
Ordered List
- First item
- Second item
- Third item
Unordered List
- First item
- Second item
- Third item
Definition List
- HTML
- HyperText Markup Language
- CSS
- Cascading Style Sheets
Hyperlinks
Visit Example.com for more information.
Special Characters
& (Ampersand)
< (Less than)
> (Greater than)
" (Double quote)
' (Single quote)
Blockquote and Cite
"This is a blockquote from another source."
The Great Gatsby by F. Scott Fitzgerald
Text Alignment
This text is centered.
This text is right-aligned.
This covers the basics of working with text in HTML. You can combine these elements and techniques to create well-structured and formatted content on your web pages.
Visit for More . . .