-2

Say I have an HTML page linking to an external stylesheet:

<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="style.css" />
        <title>Whatever Title</title>
    </head>

    <body>

    // body goes here

    </body>
</html>

Now, say I want to add another stylesheet (or 2 or 3 or 500). The usual way to do this is to have more than 1 <link> tag:

<link rel="stylesheet" type="text/css" href="style.css" />
<link rel="stylesheet" type="text/css" href="new.css" />
<link rel="stylesheet" type="text/css" href="old.css" />
...

Or maybe @importing, but I've never really done that personally. However, is there a way to have more than 1 stylesheet for a single <link> tag, probably in the href part? Perhaps something like this?

<link rel="stylesheet" type="text/css" href="style.css; new.css; old.css" />

More generally, is there a way to do this with other attributes of other tags, like with <script> tags or <a> tags (that last one would be weird)?

By the way, in case you were wondering, the syntax I used was for HTML5, but I'm sure it would be the same with HTML 4.01.

4

1 回答 1

2

不,您不能在href属性中指定多个位置。根据规范,每个都<link>代表一个连接到您的 html 的文档。因此,按照设计,它只是一份文件。

http://www.w3.org/TR/html401/struct/links.html#h-12.3

于 2013-11-08T16:56:34.517 回答