加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

HTML – 是否必须在标签内定义CSS?

发布时间:2020-12-14 18:31:44 所属栏目:资源 来源:网络整理
导读:我想在我的页面中定义一个CSS片段,如下所示: style type="text/css"hr {color:sienna;}p {margin-left:20px;}/style 我一直在读它应该在 head中定义它.元素,但内联时似乎工作正常.有人可以确认这是否可以? 解决方法 对于HTML 4规范说: The STYLE element
我想在我的页面中定义一个CSS片段,如下所示:
<style type="text/css">
hr {color:sienna;}
p {margin-left:20px;}
</style>

我一直在读它应该在< head>中定义它.元素,但内联时似乎工作正常.有人可以确认这是否可以?

解决方法

对于HTML 4规范说:

The STYLE element allows authors to put style sheet rules in the head of the document. HTML permits any number of STYLE elements in the HEAD section of a document.

Reference: http://www.w3.org/TR/html4/present/styles.html#h-14.2.3.

他们对“文件负责人”的说明,而不仅仅是“文件”强烈暗示其他地方是不合适的.

但是,对于HTML 5,这是放松的,样式元素可以放在文档本身中:

The style element allows authors to embed style information in their documents. The style element is one of several inputs to the styling processing model. The element does not represent content for the user.

Reference: http://www.w3.org/TR/html5/semantics.html#the-style-element.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读