简体   繁体   English

带有u标签的Span标签

[英]Span tag with u tag

I am having a problem with a span tag and a underline tag. 我在使用span标签和下划线标签时遇到问题。 I dont understand why I can't add a underline tag within a span tag. 我不明白为什么我不能在span标签内添加下划线标签。

Why would I be able to add i tag but not the u tag? 为什么我可以添加i标签而不添加u标签?

<span>aa bb cc 
<u>
<strong>AND</strong>
</u> 
aa bb cc </span>

The element 'span' in namespace ' http://www.w3.org/1999/xhtml ' has invalid child element 'u' in namespace ' http://www.w3.org/1999/xhtml '. 元素命名空间“跨度”“ http://www.w3.org/1999/xhtml ”在命名空间“无效的子元素“U” http://www.w3.org/1999/xhtml ”。 List of possible elements expected: 'a, br, span, bdo, map, img, tt, i, b, big, small, em, strong, dfn, code, q, samp, kbd, var, cite, abbr, acronym, sub, sup' 可能的元素列表:'a,br,span,bdo,map,img,tt,i,b,big,small,em,strong,dfn,code,q,samp,kbd,var,cite,abbr,首字母缩写,sub,sup'

Because underlining is widely used for hyperlinks on web sites, the general recommendation is not to use underline for text decoration. 因为下划线广泛用于网站上的超链接,所以一般建议不要将下划线用于文本修饰。 This, however, shouldn't keep anyone from using underline, but only serve as a recommendation that you use underline with care, so the reader intuitively can see that it is an underline, not a hyperlink. 但是,这不应阻止任何人使用下划线,而只是建议您谨慎使用下划线,因此读者可以直观地看到它是下划线,而不是超链接。

Underline can be done in two ways: 下划线可以通过两种方式完成:

The tag <u> or style="text-decoration:underline" . 标记<u>style="text-decoration:underline"

Style needs to be applied on a tag which is a text section, eg <p>, <div> and <span>. 需要在作为文本部分的标签上应用样式,例如<p>, <div> and <span>. The way underline is normally used in text, will usually be a good solution. 下划线通常在文本中使用的方式,通常是一个很好的解决方案。 As far as I have tested the two ways of underlining, they give exacly the same effect, also in combination with other styles. 就我测试过的两种强调方式而言,它们与其他样式结合使用时可产生完全相同的效果。

Officially HTML 5 does not support the u tag, and when validating the code a warning or error message will appear, but the underline appears without any problems. 正式地,HTML 5不支持u标记,并且在验证代码时将显示警告或错误消息,但是出现下划线时没有任何问题。

I don't think there's anything wrong with your code. 我认为您的代码没有任何问题。 It passes the W3C validation check here: https://validator.w3.org/nu/#textarea 它通过了W3C验证检查: https : //validator.w3.org/nu/#textarea

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM