TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Consistent use of double or single quotes in HTML

6 pointsby persandover 10 years ago

5 comments

whafroover 10 years ago
It&#x27;s nice to see pedantry validated, occasionally.<p>Still, this will invariably lead to a few arguments behind closed doors:<p>- &quot;We should obviously standardize on single quotes, since they&#x27;re shorter than double quotes and save more space!&quot;<p>- &quot;Our site serves up dozens of pageviews a day – let&#x27;s spend the next week scrubbing our markup for consistency!&quot;<p>- &quot;If you&#x27;re using mixed quotes in your markup, you&#x27;re Doing It Wrong!&quot;
collywover 10 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&#x27;t need to escape quotes by using the alternative type.<p>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.
smhendersonover 10 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&#x27;t contain a bunch of \&quot; patterns scattered throughout.<p>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
Malicover 10 years ago
I would view it as a &quot;code smell&quot; - if you aren&#x27;t concerned about mixed single&#x2F;double quote usage, then what ELSE aren&#x27;t you concerned about?
评论 #8947479 未加载
_mtrover 10 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&#x27;m copying that snippet.
评论 #8947463 未加载