为什么我们经常在head标签中添加脚本或样式 [英] Why we often add script or style in head tag

查看:179
本文介绍了为什么我们经常在head标签中添加脚本或样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我们经常在head标记中添加脚本或样式?

Why we often add script or style in head tag?

推荐答案

对于Style标记,HTML标准说它们在那里.对于脚本标签,它取决于脚本及其功能.如果您正在加载.js文件,则该文件位于标题部分.如果您希望代码作为已渲染页面的一部分执行并且它不存在于方法中,并且如果我们在谈论方法,则通常将代码移到使用它的位置或在正文的底部部分(在所有html之后).
For Style tags, the HTML standard says they go there. For script tags, it depends on the script and its function. If you''re loading a .js file, it goes in the head section. If you want the code to execute as part of the rendered page and it doesn''t live in a method, and if we''re talking about methods, it generally goes where it''s used or at the bottom of the body section (after all of your html).


这篇关于为什么我们经常在head标签中添加脚本或样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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