Html 你如何在html中引用多个.css文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2511048/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do you refer to more than one .css file in html?
提问by ggfan
I have a homepage.html and it refers to styles.css(makes a table). But I also want homepage.html to refer to styles12.css because in styles12.css I have the css for taps.
我有一个 homepage.html,它指的是 style.css(制作表格)。但我也希望 homepage.html 引用styles12.css 因为在styles12.css 中我有用于tap 的css。
how would I refer to two .css files?
我将如何引用两个 .css 文件?
<title>Testing Css/HTML files</title>
<link rel="stylesheet" type="text/css" href="style.css" />
Can I just make another <link rel="stylesheet" type="text/css" href="style12.css" />
?
我可以再做一个<link rel="stylesheet" type="text/css" href="style12.css" />
吗?
回答by ChristopheD
Yes, just add the second bit as you mentioned:
是的,只需添加您提到的第二位:
<link rel="stylesheet" type="text/css" href="style12.css" />
回答by Hugh
you can also use @import
inside other style sheets.
您也可以@import
在其他样式表中使用。
@import url("site.css");
回答by Quentin
Yes. Just use multiple link elements.
是的。只需使用多个链接元素。
Note, however, that it isn't very efficient and it is generally better to combine all your stylesheets into a single file.
但是请注意,它的效率不是很高,通常最好将所有样式表合并到一个文件中。
回答by Stefan Kendall
Yes, and the order of precedence for rules will follow the basic CSS precedence ruleset, and later rules overwrite earlier rules if they specify the same attributes.
是的,规则的优先顺序将遵循基本的 CSS 优先规则集,如果后面的规则指定了相同的属性,则它们会覆盖较早的规则。
You might want to read this article on specificity.
您可能想阅读这篇关于特异性的文章。
回答by Darren Murray
could you not just do
你能不能不做
<link href="style.css" rel="stylesheet" type="text.class">
would this work for linking more than 1 css page for each web page
这是否适用于为每个网页链接 1 个以上的 css 页面
<link href="about.css" rel="stylesheet" type="text.class>