Skip to content Skip to sidebar Skip to footer

What Css Property Is Used to Bold Text

If you work exclusively in a content direction organization like CMS Hub or WordPress, you're used to being able to bold, italicize, and underline text with a click of the push. But what if your toolbar doesn't offer the exact formatting option y'all want? Or you're not working in a give-and-take processor or a CMS?

No problem. All y'all need is some HTML and CSS. Below we'll talk over some use cases for formatting text. Then, nosotros'll walk through the process for creating assuming, italicized, underlined, strikethrough, subscript, and superscript text.

Download Now: Free Intro Guide to HTML & CSS

When bolding text, information technology's considered a best exercise to use the <stiff> tag in favor of the <b> tag. This is because the <potent> a semantic element whereas <b> is not. Non-semantic elements can make content localization and future proofing difficult, according to the HTML5 specification. Additionally, if the text bolding is purely stylistic, it'south ameliorate to use CSS and keep all folio styling separate from the content.

For this reason, nosotros'll only be showing examples using <strong> and the CSS font-weight property.

How to Bold Text in HTML with the Strong Element

To define text with potent importance, identify the text inside <potent> tags. Let'due south wait at an example.

Here'south the HTML:

                                          

<p>This is some normal paragraph text, <potent>and this is some important text.</potent></p>

Here'due south the result:

example of how to bold text in html

How to Bold Text in HTML with the CSS Font-Weight Property

To bold text but for ornamentation, use the CSS font-weight belongings instead of the HTML strong chemical element. Allow's say yous desire to assuming a word in a paragraph — you'd wrap the discussion in <bridge> tags and employ a CSS class selector to apply the font-weight holding to the specific bridge element only.

Hither's the CSS:

                                          

.bolded { font-weight: bold; }

Here'due south the HTML:

                                          

<p>This is some normal paragraph text, and this <span class="bolded">word</bridge> is bold for decoration.</p>

Here'southward the event:

example of how to bold text in html

Similar <strong> and <b>, the <em> tag is generally preferred over the <i> tag as it is a semantic element, and so we'll be using it in our HTML examples. For styling, stick with CSS and avoid the <i> tag.

How to Italicize Text in HTML with the Emphasis Element

To define text with stress accent, identify the text within <em> tags. Let'due south encounter an case.

Hither'south the HTML:

                                          

<p>This is some normal paragraph text, <em>and this is some emphasized text.</em></p>

Here's the issue:

example of how to add italics to text in html

How to Italicize Text in HTML with the CSS Font-Way Property

To italicize text for decoration, use the CSS font-way belongings. Imagine you want to italicize a word inside a paragraph. Get-go, wrap the word in <span> tags, then apply the font-fashion holding to the span element only.

Here's the CSS:

                                          

.emphasized { font-style: italic; }

Here's the HTML:

                                          

<p>This is some normal paragraph text, and this <span class="emphasized">word</span> is italicized for decoration.</p>

Here's the result:

example of how to add italics to text in html

Yous tin can besides underline text with the <u> element, but this should not be used to underline text for presentation purposes. The <u> element is meant for specific use cases like marking up misspelled words, denoting proper names in Chinese text, or indicating family names.

Let's look at both methods below.

How to Underline Text in HTML with the Unarticulated Notation Element

If you lot'd like to display text that is unarticulated or has a non-textual annotation, place the text inside <u> tags. For example:

                                          

<p>This <u>wrd</u> is misspelled, so nosotros've underlined it.</p>

Here's the result:

example of how to underline text in html

How to Underline Text in HTML with the CSS Text-Ornamentation Property

If you'd like to underline text for ornament, rather than to stand for a non-textual annotation, so you'd utilise the CSS text-ornamentation holding, similar so:

Here'due south the CSS:

                                          

.underlined {text-ornamentation: underline;}

Here's the HTML:

                                          

<p>This text is normal, and <bridge course="underlined"> this text is underlined</span>.</p>

And here's the result:

example of how to underline text in html and css

How to Render Strikethrough Text in HTML

In that location are multiple means to return strikethrough text in HTML, which is text displayed with a horizontal line through it. You can use the <s> tag to bespeak that the text is now incorrect, inaccurate, or irrelevant. If you desire to indicate text that has been deleted, use the <del> tag.

If you want to evidence the text equally strikethrough for another reason, then y'all'd use the CSS text-decoration-line property and prepare this property to "line-through."

Information technology's important to note that the HTML <strike> element has been deprecated and is no longer a viable choice for rendering strikethrough text.

Let's look at examples for the 3 methods supported in the current version of HTML.

How to Strikethrough Text in HTML with the Strikethrough Element

If yous'd like to strikethrough text to show that information technology is no longer correct, accurate, or relevant, place the text inside <s> tags. Allow's look at an example.

Hither'southward the HTML:

                                          

<p>The meeting will brainstorm at 5:00 PM on <s>Saturday</southward> now on Dominicus.</p>

Here's the result:

example of how to strikethrough text in html

How to Strikethrough Text in HTML with the Deleted Text Element

To strikethrough text to show that information technology has been deleted, identify the text within <del> tags. Let's see an instance with a list element:

Here'south the HTML:

                                          

<p>Appointments are at present bachelor for:</p>

<ul>

<li><del>iii PM</del></li>

<li><del>4 PM</del></li>

<li>5 PM</li>

</ul>

Here's the result:

example of how to strikethrough text in html

How to Strikethrough Text in HTML with the CSS Text-Decoration-Line Holding

To strikethrough text for another purpose, use the CSS text-decoration-line property.

Here's the CSS:

                                          

.strike { text-decoration-line: line-through; }

Here's the HTML:

                                          

<p>This text is normal, and <span course="strike"> this text is line-through</span>.</p>

Here's the result:

example of how to strikethrough text in html and css

How to Make Text Subscript in HTML

Normally rendered in a smaller simply heavier font, subscript text appears one-half a grapheme below the normal line. It can be used in chemical formulas, math equations, fractions, and more.

To create subscript text in HTML, use the <sub> element. See the example below.

Here's the HTML:

                                          

<p>The chemical formula for h2o is H<sub>2</sub>O.</p>

Hither'due south the event:

example of how to write subscript text in html

How to Brand Text Superscript in HTML

Usually rendered in a smaller merely heavier font, superscript text appears one-half a grapheme above the normal line. Information technology can exist used to write footnotes, copyright, registered trademarks, and some chemic formulas every bit well.

To create superscript text in HTML, use the <sup> element. Encounter the example beneath.

Here's the HTML:

                                          

<p>Water is essential for all forms of life.<sup>1</sup></p>

Hither'south the issue:

example of how to write superscript text in html

Formatting Text with HTML & CSS

Past formatting text in whatsoever of the ways described above, you lot can help your readers to amend understand and retain data from your site. Whether you desire to bold keywords or include subscript in chemical formulas, formatting text just requires basic cognition of HTML and CSS.

Editor'south note: This post was originally published in Oct 2020 and has been updated for comprehensiveness.

New Call-to-action

css introduction

Originally published Dec 10, 2021 7:00:00 AM, updated March 16 2022

blackshearreckeddens.blogspot.com

Source: https://blog.hubspot.com/website/how-to-bold-in-html

Post a Comment for "What Css Property Is Used to Bold Text"