HTML - CSS 链接顺序 [英] HTML - CSS Link Order

查看:25
本文介绍了HTML - CSS 链接顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 CodeCademy 的 html 文件中遇到了 css 链接订单.我只是无法获得链接 css 文件的逻辑.为什么我们必须按照下面这个顺序链接文件?它是否与编程有关,我们必须在使用它们之前首先定义包含函数的头文件?该逻辑是否也适用于链接 CSS 文件?有人可以为这个问题提供一个全面的解释吗?:D

I came across css link orders in a html file from CodeCademy. I just can't get the logic of linking css files. Why do we have to link the files according to this order below? Is it somehow related to programming where we must first define the header file which contains the functions before using them? Is that logic applicable at linking a CSS file too? Could someone please provide a comprehensive explanation for this question? :D

<head>
    <link href="http://s3.amazonaws.com/codecademy-content/courses/ltp/css/shift.css" rel="stylesheet">
    
    <link rel="stylesheet" href="http://s3.amazonaws.com/codecademy-content/courses/ltp/css/shift.css">
    
    <link rel="stylesheet" href="main.css">
    
</head>

属性的顺序在链接元素内重要吗?例如 和 <link rel="" href="">,与 rel 相比,将 href 作为优先级的效果是什么?

Does the order of attributes matter inside the link element? For example <link href="" rel=""> and <link rel="" href="">, what's the effect of having href as precedence compared to rel?

推荐答案

来自 CSS 规范:

最后,按指定的顺序排序:如果两个声明具有相同的权重、来源和特异性,则指定的后者获胜.导入的样式表中的声明被视为在样式表本身的任何声明之前.

Finally, sort by order specified: if two declarations have the same weight, origin and specificity, the latter specified wins. Declarations in imported style sheets are considered to be before any declarations in the style sheet itself.

顺序很重要,因为当规则发生冲突时,顺序是决定哪一方获胜的一个因素.

Order matters, because, when rules conflict, order is a factor in deciding which one wins.

这篇关于HTML - CSS 链接顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆