为了兼容老版本的浏览器,建议使用link引入外部样式表的方来代替@import导入样式的方式.
译者注:@import是CSS2.1提出的所以老的浏览器不支持,点击查看@import的兼容性。
@import和link在使用上会有一些区别,利用二者之间的差异,可以在实际运用中进行权衡。
关于@import和link方式的比较在52CSS.com上有几篇文章可以拓展阅读。
不推荐@import导入方式
ExampleSourceCode
广州网站建设,网站建设,广州网页设计,广州网站设计
- "http://www.w3.org/TR/html4/strict.dtd">
- <htmllanghtmllang="en">
- <head>
- <metahttp-equivmetahttp-equiv="content-type"content="text
- <title>Pagetitle-52css.comtitle>
- <styletypestyletype="text/css"media="screen">
- @importurl("styles.css");
- style>
- head>
- <body>...body>
- html>
推荐引入外部样式表方式
ExampleSourceCode
- "http://www.w3.org/TR/html4/strict.dtd"><htmllanghtmllang="en"><head>
- <metahttp-equivmetahttp-equiv="content-type"content="text
- <title>Pagetitle-52css.comtitle>
- <linkrellinkrel="stylesheet"href="name.css"type="text/css"media="screen"/>
- head>
- <body>...body>
- html>
三、使用继承
ExampleSourceCode
- 低效率的
- p{font-family:arial,helvetica,sans-serif;}
- #container{font-family:arial,helvetica,sans-serif;}
- #navigation{font-family:arial,helvetica,sans-serif;}
- #content{font-family:arial,helvetica,sans-serif;}
- #sidebar{font-family:arial,helvetica,sans-serif;}
- h1{font-family:georgia,times,serif;}
- 高效的
- body{font-family:arial,helvetica,sans-serif;}
- body{font-family:arial,helvetica,sans-serif;}
- h1{font-family:georgia,times,serif;}



