如何使用 HTML5 显示错误内容?
在 HTML 中,我们有两个元素,即 s
和 del
,用于显示错误内容。‘s’ 和 ‘del’ 标签之间没有实验上的区别,也没有证据表明搜索引擎会对这些元素采取任何措施。
例如
假设有两句话,用于查看错误句子与正确句子之间的区别。正确句子与普通文本相同,而错误句子则用黑色删除线标记。
语法
<s>
<s>
标签表示删除线或横线文本,即不再正确或精确。
<del>
<del>
表示已删除的文本或已移除的文本,会在句子或单词上划一条删除线。
使用属性
以下属性用于下面的示例:
color - 此属性定义文本的颜色。
font-size - 此属性定义文本的高度。
font-weight - 此属性定义文本属性的显示方式,例如正常、粗体、超粗体等。
Explore our latest online courses and learn new skills at your own pace. Enroll and become a certified expert to boost your career.
示例 1
在本例中,我们将使用段落、s
和 del
等元素显示正确和错误的句子。然后使用内部 CSS 设计 h1
和 p
元素的部分,以更好地表达网页。
<!DOCTYPE html> <html> <title>Tutorialspoint</title> <head> <style> h1{ color: Purple; } p{ font-weight: bold; } </style> </head> <body> <center> <h1>Correct VS Incorrect Sentence</h1> <p>I shall make him to go</p> <s><p>I shall make him go</p></s> <p>He will come for meeting you</p> <s><p>He will come to meet you</s></p> <p>Always help the poor</p> <del><p>Always helps the poor's</p></del> </center> </body> </html>
示例 2
在本例中,我们将使用内部 CSS 设置两个类,即 tp
和 gp
来设置属性。tp 类设置 div 元素的属性,而 gp 类设置另一个 div 元素的属性,该元素使用 s
和 del
元素显示错误内容。
<!DOCTYPE html> <html> <title>Tutorialspoint</title> <head> <style> .tp{ font-size: 40px; font-weight: bold; color: darkgreen; } .gp{ font-weight: bold; color: darkred; } </style> </head> <body> <h1>The incorrect content using HTML5</h1> <div class="tp"> Tutorialspoint </div> <div class="gp"> The front-end development skill includes <s> ML, Arduino, Fortran,</s> HTML5, CSS3, <del> Jailwind CSS </del> and, JavaScript. </div> </body> </html>
结论
我们探讨了使用 HTML5 显示错误内容的概念。我们看到两个示例的输出有一些变化,即通过定义 style
标签来设置元素的样式。示例的主要目的是了解 <s>
和 <del>
标签之间的区别,它们显示出类似的行为。
广告