html - html属性和值之间的空格?

他们被允许吗?它们是否适用于所有浏览器?

例子:

<div role = "region"
     id = "some-id"
     class = "a-class another-class">

最佳答案

是的,任何数量的空格都是允许的,并且适用于所有浏览器。

来自 Attributes section of the HTML5 living standard关于不带引号、单引号和双引号的属性值语法:

The attribute name, followed by zero or more ASCII whitespace, followed by a single U+003D EQUALS SIGN character, followed by zero or more ASCII whitespace, [...]

一个考虑因素 - 这会增加页面大小,因此如果需要考虑带宽和性能,请尝试限制您使用的空白数量。

https://stackoverflow.com/questions/7064095/

相关文章:

layout - 更改 latex 文档中间的纸张尺寸?

c# - 获取格式化字符串以表示 UTC 偏移量的最佳方法是什么?

ruby-on-rails - Ruby on Rails 中的自定义格式

javascript - json 值中的单引号

html - 动态生成的 HTML 的格式 - 没人关心吗?

excel - 带硬停止的条件格式颜色渐变

sql-server - SQL Server 2008 : how to format the o

algorithm - 需要一种算法来拆分一系列数字

text - 为什么 LaTeX 会忽略文档类中的字体大小

c# - Linq 2 Sql DateTime 格式为字符串 yyyy-MM-dd