如果我把css文件里面< head>有什么区别或< body>? [英] What's the difference if I put css file inside <head> or <body>?

查看:136
本文介绍了如果我把css文件里面< head>有什么区别或< body>?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,css文件放在< head>< / head> 内,如果我把它放在< body> / body> ,它会有什么区别?

Normally css files are put inside <head></head>, what if I put it inside <body></body>, what difference will it make?

推荐答案

只是添加到jdelStrother提到的关于w3 specs和ARTstudio的浏览器渲染。

Just to add on to what jdelStrother has mentioned about w3 specs and ARTstudio about browser rendering.

建议因为当你在< body> 之前声明了CSS时,你的样式实际上已经加载了。因此,用户很快就会看到屏幕上显示的内容(例如背景颜色)。

It is recommended because when you have the CSS declared before <body> starts, your styles has actually loaded already. So very quickly users see something appear on their screen (e.g. background colors). If not, users see blank screen for some time before the CSS reaches the user.

此外,如果你把样式留在< ; body> ,当声明的样式已被解析时,浏览器必须重新渲染页面(加载时是新的和旧的)。

Also, if you leave the the styles somewhere in the <body>, the browser has to re-render the page (new and old when loading) when the styles declared has been parsed.

这篇关于如果我把css文件里面&lt; head&gt;有什么区别或&lt; body&gt;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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