Html 在body标签中加载外部css文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4957446/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 06:38:43  来源:igfitidea点击:

load external css file in body tag

htmlcss

提问by Jinbom Heo

Possible Duplicate:
What's the difference if I put css file inside <head> or <body>?

可能的重复:
如果我将 css 文件放在 <head> 或 <body> 中有什么区别?

usually, external css file loading code is put on header of html.

通常,外部 css 文件加载代码放在 html 的标题上。

<head>

...
<link href="/uploadify/uploadify.css" type="text/css" rel="stylesheet" />
...

</head>

but, sometime I should put my css loading code in body tag, I mean..

但是,有时我应该将我的 css 加载代码放在 body 标签中,我的意思是..

<body>
...
<link href="/uploadify/uploadify.css" type="text/css" rel="stylesheet" />
...
</body>

so my question is, is it okay to put my css loading code in body tag?

所以我的问题是,可以将我的 css 加载代码放在 body 标签中吗?

回答by Daan

No, it is not okay to put a linkelement in the body tag. See the specification(links to the HTML4.01 specs, but I believe it is true for all versions of HTML):

不,link在 body 标签中放置元素是不行的。查看规范(链接到 HTML4.01 规范,但我相信所有版本的 HTML 都是如此):

“This element defines a link. Unlike A, it may only appear in the HEADsection of a document, although it may appear any number of times.”

“这个元素定义了一个链接。与 不同A,它可能只出现在HEAD文档的某个部分,尽管它可能出现多次。”