在HTML元素属性的`=`符号之前和之后使用空格 [英] Using spaces before and after the `=` sign of HTML element attribute

查看:441
本文介绍了在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)" />

这篇关于在HTML元素属性的`=`符号之前和之后使用空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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