html - css的级联顺序

标签 html css

<!DOCTYPE html>
<html>
<head>
<style>
img { 
    width:100%; 
}
</style>
</head>
<body>

<img src="html5.gif" alt="HTML5 Icon" style="width:128px;height:128px;">
<img src="html5.gif" alt="HTML5 Icon" width="128" height="128">

</body>
</html>

嗨,我有一个问题,为什么 <style>覆盖 <img src="html5.gif" alt="HTML5 Icon" width="128" height="128"> .对于订单,内联元素是否比文档级别更高??

最佳答案

参见 the CSS2 specification :

The UA may choose to honor presentational attributes in an HTML source document. If so, these attributes are translated to the corresponding CSS rules with specificity equal to 0, and are treated as if they were inserted at the start of the author style sheet. They may therefore be overridden by subsequent style sheet rules. In a transition phase, this policy will make it easier for stylistic attributes to coexist with style sheets.

关于html - css的级联顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64196959/

相关文章:

javascript - 在页面左侧和右侧显示 Bootstrap 井

html - 偏移 html 元素/标签后面的背景

html - 使用 bootstrap 3 时如何强制图像最大宽度?

javascript - 为动态创建的html标签添加点击功能

javascript - Meteor中 'same-named' HTML和JS文件之间有什么特殊关系吗?

javascript - Chrome 应用程序 将一个页面打开到另一个页面

html - 大卡特尔 - 网站标题

css - 使用 nth-child 减少最后 4 个容器

html - 为什么我的标题在两行时给出这个渲染?

javascript - 如何放大CSS按钮的可点击?