💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# CSS text-decoration 属性 ## 实例 设置 h1、h2、h3、h4 元素的文本修饰: ``` h1 {text-decoration:overline} h2 {text-decoration:line-through} h3 {text-decoration:underline} h4 {text-decoration:blink} ``` ## 浏览器支持 | IE | Firefox | Chrome | Safari | Opera | | --- | --- | --- | --- | --- | 所有主流浏览器都支持 text-decoration 属性。 注释:任何的版本的 Internet Explorer (包括 IE8)都不支持属性值 "inherit"。 注释:IE、Chrome 或 Safari 不支持 "blink" 属性值。 ## 定义和用法 text-decoration 属性规定添加到文本的修饰。 注释:修饰的颜色由 "color" 属性设置。 ### 说明 这个属性允许对文本设置某种效果,如加下划线。如果后代元素没有自己的装饰,祖先元素上设置的装饰会“延伸”到后代元素中。不要求用户代理支持 blink。 | 默认值: | none | | --- | --- | | 继承性: | no | | --- | --- | | 版本: | CSS1 | | --- | --- | | JavaScript 语法: | _object_.style.textDecoration="overline" | | --- | --- | ## 可能的值 | 值 | 描述 | | --- | --- | | none | 默认。定义标准的文本。 | | underline | 定义文本下的一条线。 | | overline | 定义文本上的一条线。 | | line-through | 定义穿过文本下的一条线。 | | blink | 定义闪烁的文本。 | | inherit | 规定应该从父元素继承 text-decoration 属性的值。 | ## TIY 实例 [修饰文本](/tiy/t.asp?f=csse_text-decoration) 本例演示如何向文本添加修饰。 ``` <html> <head> <style type="text/css"> h1 {text-decoration: overline} h2 {text-decoration: line-through} h3 {text-decoration: underline} h4 {text-decoration:blink} a {text-decoration: none} </style> </head> <body> <h1>这是标题 1</h1> <h2>这是标题 2</h2> <h3>这是标题 3</h3> <h4>这是标题 4</h4> <p><a href="http://www.w3school.com.cn/index.html">这是一个链接</a></p> </body> </html> ``` ## 相关页面 CSS 教程:[CSS 文本](/css/css_text.asp "CSS 文本") HTML DOM 参考手册:[textDecoration 属性](/jsref/prop_style_textdecoration.asp "HTML DOM textDecoration 属性")