HTML provides a variety of tags and attributes for formatting text. These tags are used to modify the appearance of text, including font styles, size, alignment, and other properties. The purpose of HTML formatting is to make content more readable, visually appealing, and structured on a webpage.
Here are the most commonly used HTML tags for formatting text:
The <b>
tag is used to bold text. It makes the text appear darker and thicker.
<b>This is bold text.</b>
This is bold text.
The <i>
tag is used to italicize text, which tilts the letters to the right.
<i>This is italic text.</i>
This is italic text.
The <:u>
tag is used to underline text.
<u>This text is underlined.</u>
This text is underlined.
The <s>
tag is used to strike through text, indicating that the text is no longer valid or relevant.
<s>This text is struck through.</s>
This text is struck through.
The <sup> tag is used to display text as superscript, typically used for footnotes or mathematical exponents.
<sup>2</sup>
This is an example of a superscript: 2nd.
The <sub> tag is used to display text as subscript, typically used in chemical formulas or mathematical expressions.
<sub>2</sub>
This is an example of a subscript: H2O.
You can change the alignment of text within an element using the text-align CSS property. The default alignment is left, but it can be modified to center or right-align text.
Text is left-aligned by default, meaning it will start from the left edge of the container.
You can center-align text by using the text-align CSS property:
<p style="text-align: center;">This paragraph is centered.</p>
This paragraph is centered.
Similarly, you can right-align text:
<p style="text-align: right;">This paragraph is right-aligned.</p>
This paragraph is right-aligned.
To create an indentation at the beginning of a paragraph, use the text-indent CSS property. Here’s an example:
<p style="text-indent: 30px;">This paragraph has an indentation at the start.</p>
This paragraph has an indentation at the start.
HTML allows you to change the color and size of the text using inline styles or external CSS.
The color CSS property allows you to change the color of text. You can use color names, RGB values, or hex codes.
<p style="color: blue;">This text is blue.</p>
This text is blue.
The font-size CSS property controls the size of the text. You can specify the size in pixels, ems, or percentages.
<p style="font-size: 20px;">This text is 20 pixels in size.</p>
This text is 20 pixels in size.
You can also modify the style and weight of text using CSS properties like font-family, font-weight, and font-style:
The font-family property allows you to specify the font type. If the font is not available, the browser will use a fallback font.
<p style="font-family: Arial, sans-serif;">This text uses Arial font.</p>
This text uses Arial font.
The font-weight property controls the thickness of the text. You can use values like normal, bold, bolder, or numeric values.
<p style="font-weight: bold;">This text is bold.</p>
This text is bold.
The font-style property can be used to italicize text:
<p style="font-style: italic;">This text is italicized.</p>
This text is italicized.
Text decoration allows you to add decorations like underlines, overlines, and line-throughs using CSS. The text-decoration property is used for this purpose.
<p style="text-decoration: underline;">This text is underlined.</p>
This text is underlined.
In summary, HTML offers a wide variety of tags and CSS properties to format text. You can modify the text's appearance using properties like font-style, font-size, color, and text-align. These formatting techniques help create visually appealing and readable content on webpages. Mastering these tools is essential for web development and design.
HTML provides a variety of tags and attributes for formatting text. These tags are used to modify the appearance of text, including font styles, size, alignment, and other properties. The purpose of HTML formatting is to make content more readable, visually appealing, and structured on a webpage.
Here are the most commonly used HTML tags for formatting text:
The
<b>
tag is used to bold text. It makes the text appear darker and thicker.
<b>This is bold text.</b>
This is bold text.
The
<i>
tag is used to italicize text, which tilts the letters to the right.
<i>This is italic text.</i>
This is italic text.
The
<:u>
tag is used to underline text.
<u>This text is underlined.</u>
This text is underlined.
The
<s>
tag is used to strike through text, indicating that the text is no longer valid or relevant.
<s>This text is struck through.</s>
This text is struck through.
The <sup> tag is used to display text as superscript, typically used for footnotes or mathematical exponents.
<sup>2</sup>
This is an example of a superscript: 2nd.
The <sub> tag is used to display text as subscript, typically used in chemical formulas or mathematical expressions.
<sub>2</sub>
This is an example of a subscript: H2O.
You can change the alignment of text within an element using the text-align CSS property. The default alignment is left, but it can be modified to center or right-align text.
Text is left-aligned by default, meaning it will start from the left edge of the container.
You can center-align text by using the text-align CSS property:
<p style="text-align: center;">This paragraph is centered.</p>
This paragraph is centered.
Similarly, you can right-align text:
<p style="text-align: right;">This paragraph is right-aligned.</p>
This paragraph is right-aligned.
To create an indentation at the beginning of a paragraph, use the text-indent CSS property. Here’s an example:
<p style="text-indent: 30px;">This paragraph has an indentation at the start.</p>
This paragraph has an indentation at the start.
HTML allows you to change the color and size of the text using inline styles or external CSS.
The color CSS property allows you to change the color of text. You can use color names, RGB values, or hex codes.
<p style="color: blue;">This text is blue.</p>
This text is blue.
The font-size CSS property controls the size of the text. You can specify the size in pixels, ems, or percentages.
<p style="font-size: 20px;">This text is 20 pixels in size.</p>
This text is 20 pixels in size.
You can also modify the style and weight of text using CSS properties like font-family, font-weight, and font-style:
The font-family property allows you to specify the font type. If the font is not available, the browser will use a fallback font.
<p style="font-family: Arial, sans-serif;">This text uses Arial font.</p>
This text uses Arial font.
The font-weight property controls the thickness of the text. You can use values like normal, bold, bolder, or numeric values.
<p style="font-weight: bold;">This text is bold.</p>
This text is bold.
The font-style property can be used to italicize text:
<p style="font-style: italic;">This text is italicized.</p>
This text is italicized.
Text decoration allows you to add decorations like underlines, overlines, and line-throughs using CSS. The text-decoration property is used for this purpose.
<p style="text-decoration: underline;">This text is underlined.</p>
This text is underlined.
In summary, HTML offers a wide variety of tags and CSS properties to format text. You can modify the text's appearance using properties like font-style, font-size, color, and text-align. These formatting techniques help create visually appealing and readable content on webpages. Mastering these tools is essential for web development and design.
Use the <link> tag inside the <head> to attach an external CSS file.
Comments in HTML are written between <!-- and -->.
HTML entities are used to display reserved or special characters.
The <iframe> tag embeds another webpage within the current page.
The id attribute uniquely identifies a single HTML element.
Hyperlinks are created using the <a> tag with an href attribute.
Use the <img> tag and specify the image source with the src attribute.
Use the target="_blank" attribute inside the <a> tag.
Copyrights © 2024 letsupdateskills All rights reserved