我们为什么使用< script>用于脚本,但不能用于< style>对于外部CSS? [英] Why do we use <script> for scripts, but not <style> for external CSS?

查看:96
本文介绍了我们为什么使用< script>用于脚本,但不能用于< style>对于外部CSS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一个亲戚开始学习Web开发时问了我这个问题.

A relative of mine who started to learn Web Development asked me this question.

为什么<script src="min.js"></script><link rel="stylesheet" href="min.css">?为什么不<style href="min.css"></style>.为什么我们使用link标签在页面中添加外部CSS,但是当我们将CSS链接到页面却在<head>内部编写CSS时却使用<style>...</style>?

Why <script src="min.js"></script> and <link rel="stylesheet" href="min.css">? Why not <style href="min.css"></style>. Why do we use link tag to add external CSS in the page but when we link CSS to page but we use <style>...</style> when we write CSS inside <head>?

我告诉他这是因为规格.还有更多信息要给他吗?

I told him that it's because of spec. Is there any more info to give to him?

推荐答案

这是历史...巧合吗?您可以推荐他阅读有关divinetohtml5.info的过去的部分,其中有一些有趣的故事,实际上是Web开发人员之间的邮件通信. Web开发人员实际上是 正在开发我们今天看到的Web;)

It's historical... coincidence? You can recommend him reading part about Past of diveintohtml5.info, where there are some interesting stories, actually mail correspondences, between web developers. Web developers means they were, in fact, developing the Web we see nowadays ;)

<img>标签,我们习惯于:

<IMG SRC="file://foobar.com/foo/bar/blargh.xbm">

可能是:

<ICON name="NoEntry" href="http://note/foo/bar/NoEntry.xbm">

<A HREF="..." INCLUDE>See photo</A>

<INCLUDE HREF="...">

但是最终,开发人员决定坚持使用已经实施的<img> :

我们目前不准备支持INCLUDE/EMBED. …所以我们 可能会一起使用(不是ICON,因为不是全部 内联图像可以有意义地称为图标).暂且, 内联图像不会明确地进行内容类型化;在路上,我们 计划对此进行支持(以及MIME的一般改编). 实际上,我们目前正在使用的图像读取程序 即时显示图片格式,因此文件扩展名甚至不会 重要的.

We’re not prepared to support INCLUDE/EMBED at this point. … So we’re probably going to go with (not ICON, since not all inlined images can be meaningfully called icons). For the time being, inlined images won’t be explicitly content-type’d; down the road, we plan to support that (along with the general adaptation of MIME). Actually, the image reading routines we’re currently using figure out the image format on the fly, so the filename extension won’t even be significant.

我不知道您的问题的直接答案,但是我对<link>标签也很好奇.寻找答案可能包括挖掘一些网络档案.

I don't know direct answer to your question, but I'm pretty curious about <link> tag, too. Finding answer would probably include some web archives digging.

这篇关于我们为什么使用&lt; script&gt;用于脚本,但不能用于&lt; style&gt;对于外部CSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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