在HTML元素属性的`=`符号之前和之后使用空格

问题描述:

我想知道是否有一个最好的方法,在一个HTML页面中的等号之前和之后有一个空格,当你写下来。似乎没有人使用这个,但对我来说,它似乎相当自然来自编程语言,这是印在他们的基本代码风格。那么,是否有任何标准,你必须在HTML元素的属性的等号之前和之后使用空格?

I am wondering if there's a "best" approach to having a space before and after the equal sign in a HTML page when you write it down. It seems like no one is using this, but for me it seems fairly natural coming from programming languages that have this printed in their basic code style. So, is there any standard that you have to not use space before and after the equal sign of an attribute of an HTML element ?

在属性名称和它的值之间没有空格分隔符实际上提高了可读性,因为它可视化地显示了它们之间的耦合。这是一个示例。

Not having a space delimiter between attribute name and its value actually improves the readability, as it visually shows the coupling between these. Here's an example.

没有空格分隔符:

<link rel="stylesheet" type="text/css" href="/css/screen-iphone.css" title="My Site" media="only screen and (max-device-width: 480px)" />

空格分隔符:

<link rel = "stylesheet" type = "text/css" href = "/css/screen-iphone.css" title = "My Site" media = "only screen and (max-device-width: 480px)" />