How to underline text in HTML (with pictures)

Table of contents:

How to underline text in HTML (with pictures)
How to underline text in HTML (with pictures)
Anonim

The legacy method of underlining in HTML is to use tags, but the modern CSS-based method is now used. Underlining is considered a bad way to draw attention to text because it is easy to confuse underlined text with a link.

Steps

Method 1 of 2: Modern Method

2475553 1 1
2475553 1 1

Step 1. Use the "text-decoration" property in CSS

Currently, the tag is not used to underline text.

By adding this property, you don't have to change your code in the future when old tags go out of circulation

2475553 2 1
2475553 2 1

Step 2. Use a tag to underline a specific piece of text

Enter a start tag along with the "text-decoration" property in front of the text you want to underline. At the end of the text, enter an end tag.

This text will be underlined.

2475553 3 1
2475553 3 1

Step 3. Specify HTML elements in the section to make it easier to underline

It can also be done using a CSS stylesheet. For example, to underline all level 3 headings, add the following code to the "style" section:

    

This heading will be underlined

2475553 4 1
2475553 4 1

Step 4. Create a CSS class to quickly underline text

You can create classes in a style sheet or section to call them later. The class can be given any name.

     Use this class to quickly underline various elements  
2475553 5 1
2475553 5 1

Step 5. Think of other ways to highlight the text

We recommend that you avoid underlining to avoid confusing users. Better to use a tag to make the text italic. Use CSS to add other styling options to this tag.

     Anything in the "em" element will be italicized (default) and also colored red thanks to the additional styling options.  

Method 2 of 2: Legacy Method

2475553 6 1
2475553 6 1

Step 1. Avoid using old tags

They are deprecated, which means that these tags still work, but are being discouraged or discouraged. This is because HTML is not meant to customize the style of content. The tag still works, but must represent text that is different from other text, such as misspelled words or Chinese proper names.

2475553 7 1
2475553 7 1

Step 2. Use tags to underline elements (for demonstration only)

There is hardly a single case where you need to use these tags. You may need to edit the old site, so it's best to be aware of what these tags are.

  Old HTML tag  allows you to quickly underline elements , but if other elements of the style were touched, everything became chaotic. Therefore, nowadays they use the "text-decoration" CSS element for underlining.  

Popular by topic