Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
574 views
in Technique[技术] by (71.8m points)

coding style - Using spaces before and after the `=` sign of HTML element attribute

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 ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

No spaces delimiter:

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

Space delimiter:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...