2 ms·
When writing my code for myself only, I don’t quote my attribute values unless necessary. If writing in a shared project, I will match the existing style, which
by chrismorgan 6y ago
When writing my code for myself only, I don’t quote my attribute values unless necessary. If writing in a shared project, I will match the existing style, which is almost always to use quotes.
But things that bother me much more are:
• Putting type="text/javascript" on <script> and type="text/css" on <link rel=stylesheet>. These are 100% useless and I can’t think of any justification for people choosing to write them that way, whereas I can easily for quotes on attribute values.
• Trailing slashes on HTML tags. As far as the parser is concerned, these are completely useless in HTML (though not SVG or MathML). The spec basically says “oh, there’s a trailing slash on the tag? Sigh, don’t they know XHTML died? Skip it.” Worse, I think they’re actively slightly harmful because they may make people think that you can close tags that way, like in XML. You can’t. The trailing slash is only valid on void tags like <img>, where there is no closing tag, and the parser only special-cases ignoring it for convenient compatibility with XHTML/XML documents.
- astura 6y ago> I can’t think of any justification for people choosing to write them that way My editor does that, not me.
- chrismorgan 6y agoHuh. Which editor? I might consider filing a bug report.
- timw4mail 6y agoTrailing slashes are valid on empty tags, such as <img> <input> <link> <base> <meta>. They are not valid on block tags.
- chrismorgan 6y ago… that’s exactly what I said.