Html 如何在 HTML5 中为 <td> 文本添加下划线

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7578495/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 10:50:07  来源:igfitidea点击:

How to add underline of a <td> text in HTML5

html

提问by Romi

I am using HTML5, when I use <u></u>tag for underline, it says that it is unsupported by HTML5. What can I use in place of this for underlining?

我正在使用 HTML5,当我使用<u></u>标记作为下划线时,它说它不受 HTML5 支持。我可以用什么代替它来下划线?

回答by zellio

You are looking for the text-decorationdirective in CSS. As underlined text is a matter of styling and not of layout, it is better relegated to a stylesheet.

您正在寻找text-decorationCSS 中的指令。由于带下划线的文本是样式问题而不是布局问题,因此最好将其降级为样式表。

Which can be use as such, which will apply the style to all <td>elements on the page

可以这样使用,它将样式应用于<td>页面上的所有元素

td {
    text-decoration: underline;
}

In CSS if you want a more targeted method of apply style, one way to go about this is with the class attribute of a tag <td class="className">. In CSS classes are defined with a leading full-stop.

在 CSS 中,如果您想要一种更有针对性的应用样式方法,一种方法是使用标签的 class 属性<td class="className">。在 CSS 类中定义了一个领先的句号。

.className {
    /* relevant style */
}

so in the case of underlining you specific <td>tags. A method would be:

所以在强调你特定<td>标签的情况下。一种方法是:

.underline {
    text-decoration: underline;
}

<td class="underline">Here be underline</td><td>Here not be underline</td> ...

Further information on the form and ussage of CSS can he found at Css Basics

关于 CSS 的形式和用法的更多信息可以在Css Basics 中找到

回答by Maddy

One approch to this

对此的一种方法

<td><span class='underline'>${user.status}</span></td>
 <td><u>${user.action}</u></td>

In css create a class

在css中创建一个类

.underline {
    text-decoration: underline;
}