How do you *personally* prefer to write HTML attributes?
@Edent In my vi-edited source text, which I try to keep XHTML-compliant, I prefer and use "", but in any auto-generated or minified HTML5 output I strip them where possible for some significant % savings.
(The savings are enough that one of the WebPageTest warnings has been modified to ack my ability to bend spacetime with this one weird trick!)
PS. May I also complain about something unrelated such as coffee-non-provision in the PGR kitchen at uni, please?
@Edent When written HTML for something I want to maintain in the long run: double quotes. When I'm using JSX/Vue, single quotes (because Standard JS linting rules seem to apply to it and I just follow to avoid bikeshedding). Otherwise, I used no quotes a lot of times in the spirit of "YEAH! HTML5! I don't need <head> nor quotes! YOLO!"
I'm on team double-quotes, but I don't really understand why.
So I think I'm going to rewrite my HTML (yet again) to exclude them where possible.
I wish languages like HTML and PHP had a separate string delimiter which wasn't a single or double quote.
Something like:
$string = ❝He said "isn't it nice?"❞;
@Edent Not sure if this helps you, but back in, I think, 1999, I decided to use single quotes for JavaScript and double quotes for HTML, mostly to set a rule. I vaguely evangelised this for a few years, though doing it the other way around was also fine by me.
But at least I understand exactly why I'm on team double-quote.
@Edent double quotes for HTML, single quotes for CSS and JavaScript. No idea why, but it’s the convention I’ve seen most often.
@Edent Rather than rewrite anything by hand, why not use a minifier to make that and many other optimisations systematically, eg stripping optional closing tags, sorting attributes and class names, collapsing whitespace, etc...
@Edent I suspect that my preference for double quotes is from the first programming language I learned (Microsoft Level II BASIC on the TRS-80).