Home > Article > Web Front-end > How to set html underline? HTML underline style example analysis
This article mainly talks about the setting method of HTML underline, as well as the setting examples of HTML underline. This article is all operated with css style. I hope everyone can master more basic knowledge of css style.
First of all, we have to talk about how to set the underline:
We know that there is an underline u tag in the HTML tag ( is underlined) , adding the html underline tag u to the text font that needs to be underlined can simply implement the underline style. But in DIV CSS layout, sometimes CSS is needed to achieve the underline style effect, that is, css underline style.
1.CSS underline style word:
text-decoration
2.CSS underline code:
text-decoration:underline
3.css Underline code demonstration:
div{text-decoration:underline}
Add underline style to the text within the div.
Now let’s talk about the CSS font underline style example:
The following is a CSS underline setting example. The example content sets the underline style for several words in a paragraph of text.
The example code for setting the underline CSS style is as follows:
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>PHP中文网:设置下划线实例</title> <style> .exp{ text-decoration:underline} </style> </head> <body> 欢迎访问PHP中文网,<span class="exp">我被加下划线样式</span>! </body> </html>
The above adds an underline style to some text in a paragraph. As shown in the screenshot below:
Finally, let’s talk about the summary of div css underline settings:
Maybe you will think that we will use it HTML U tag is underlined, why should we use CSS text-decoration style to underline it? This is because the CSS layout is ever-changing to achieve various layouts. In order to meet different needs, the CSS styles that can be implemented by general HTML tags can be implemented. Sometimes using CSS implementation can facilitate later modification and maintenance. But on the contrary, it is not that learning CSS means not using HTML tags to achieve the required styles, but that sometimes HTML tags and CSS styles are selected and laid out according to needs to find the most suitable layout for the project, which is the important essence of DIV CSS layout. Achieve the simplest code, easy code maintenance, search engine ranking consideration, easy use by programmers, etc.
Okay, that’s the entire content of this article. If you have any questions, you can ask them below.
【Editor’s Recommendation】
html Is the tbody tag a block-level element? Basic usage of html tbody tag
The above is the detailed content of How to set html underline? HTML underline style example analysis. For more information, please follow other related articles on the PHP Chinese website!