内联样式作品不带引号 [英] Inline style works without quotes

查看:171
本文介绍了内联样式作品不带引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我有这把小提琴.您可以清楚地看到我缺少内联样式的引号,但仍然可以正确显示.从我所学的地方,他们从未说过允许不使用引号.那么,是这样吗?

I have , for example , this fiddle . You can clearly see I am missing the quotes in the inline-style , but still it does show up correctly . From wherever I have learned , never did they say that not using quotes is allowed . So , is this:

  • jsFiddle中的错误
  • 预期功能.如果是这样,那么为什么要教我们使用引号.
  • (您可能会建议的事情)
<div style=background-color:red></div>This styling is weird

stylesheet.css

div{ height:500px ; width:500px }

谢谢.

推荐答案

HTML属性的报价被认为是可选的(对于HTML,不是XHTML),但是在某些情况下,您可能会遇到一些问题.

Quotes for HTML attributes are considered optional (for HTML, not XHTML), however there are some cases where you may run into some problems.

例如

<a title=Hi, mom! href=#>

这是无效的,因为'Hi'和'mom!'之间有空格.引号将语句分组在一起.

This isn't valid because of the space between 'Hi' and 'mom!'. Quotes group the statement together.

<div rel=a&b></div>

Rel值在包括IE 9和10在内的所有现代浏览器中均被视为"a& b".IE6、7和8将该值视为"a".

Rel value seen as "a&b" in all modern browsers including IE 9 and 10. IE 6, 7, and 8 see the value as "a".

更多示例可以在这里找到: http://css-tricks.com/problems-with-unquoted-attributes/

More examples can be found here: http://css-tricks.com/problems-with-unquoted-attributes/

这篇关于内联样式作品不带引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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