HTML - 是否有必要将对css文件的调用引入引号中? [英] HTML - Is it necessary to enclose a call to the css file into quotes?

查看:107
本文介绍了HTML - 是否有必要将对css文件的调用引入引号中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.html文件和ist .css文件。我通过指令调用.css。

 < link rel = stylesheet href = mystyle.css> 

但如果我使用

 < link rel =stylesheethref =mystyle.css> 

然后在我的页面中没有任何变化。使用引号还是有一些区别?

解决方案

我相信该规范将其定义为引号,但某些浏览器超出并会知道您的意思。 >

编辑:我错了!来自规范


属性放置在开始标记内,由名称和值组成,由=字符分隔。如果属性值不包含空格字符或任何''`=< or>,则该属性值可以保持不加引号。否则,必须使用单引号或双引号引用该值。值和=字符,如果值为空字符串,可以完全省略。


http://www.w3.org/html/wg /drafts/html/master/introduction.html#restrictions-on-content-models-and-on-attribute-values


I have a .html file and ist .css file. I call the .css trough the instruction

<link rel= stylesheet href= mystyle.css>

But if I use

<link rel= "stylesheet" href= "mystyle.css">

then nothing changes in my page. Is there some difference between using the quotes or not?

解决方案

I believe the spec defines it to have quotes, but some browsers go beyond and will know what you meant.

EDIT: I was wrong! From the spec

Attributes are placed inside the start tag, and consist of a name and a value, separated by an "=" character. The attribute value can remain unquoted if it doesn't contain space characters or any of " ' ` = < or >. Otherwise, it has to be quoted using either single or double quotes. The value, along with the "=" character, can be omitted altogether if the value is the empty string.

http://www.w3.org/html/wg/drafts/html/master/introduction.html#restrictions-on-content-models-and-on-attribute-values

这篇关于HTML - 是否有必要将对css文件的调用引入引号中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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