Settings

Theme

Consistent use of double or single quotes in HTML

labs.kollegorna.se

6 points by persand 11 years ago · 7 comments

Reader

whafro 11 years ago

It's nice to see pedantry validated, occasionally.

Still, this will invariably lead to a few arguments behind closed doors:

- "We should obviously standardize on single quotes, since they're shorter than double quotes and save more space!"

- "Our site serves up dozens of pageviews a day – let's spend the next week scrubbing our markup for consistency!"

- "If you're using mixed quotes in your markup, you're Doing It Wrong!"

collyw 11 years ago

So basically it comes down to insignificant performance and size boost. The reason for being able to mix them is so you don't need to escape quotes by using the alternative type.

I think consistency makes code look nicer and perhaps a bit more readable, but lets not kid ourselves that this leads to any meaningful improvements.

smhenderson 11 years ago

Most of my HTML is generated by Perl so I am the opposite. Alls string vars at the Perl level are wrapped in double quotes in case interpolation is necessary. Attributes are wrapped in single quotes so my Perl code doesn't contain a bunch of \" patterns scattered throughout.

I totally agree about consistency though; I even take the minor performance hit when interpolation is unnecessary by using double quotes anyway so that all uses of double and single quotes are consistent

Malic 11 years ago

I would view it as a "code smell" - if you aren't concerned about mixed single/double quote usage, then what ELSE aren't you concerned about?

_mtr 11 years ago

The first thing that came to mind when reading the title of this post was Google Fonts. Maybe this is validation that I need to write that Chrome extension that comes to mind every time I'm copying that snippet.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection