DEV Community

Discussion on: Are you 'using' "useless" "\"QUOTES\""?

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀 • Edited

It's not about what's valid or not valid, what you can leave out or what you cannot. I know that quoteless attributes are valid, I know that only the left li is needed. I know that e is counted as a number. But what counts when working with others is time tested idomatic html so you better start using quotes even if you don't want to.

The author is correct however!

Collapse
 
rsp profile image
Rafał Pocztarski

I wrote that way exactly 25 years ago so I would argue that it is actually quite time tested and idiomatic. ;) Just to let you know, I always respect the style used in projects when I work in teams, so you won't find me adding any code in a different style that is used in the project. But I argue against using redundant attributes like type="application/ecmascript" or type="text/css" that is not only not needed but can be inconsistent with the actual Content-Type headers that are used anyway. And yes, I also quote attributes when I write professional code. But it puzzles me that people insist on quoting simple attributes in HTML like <div id="abc"> while I've never seen anyone insisting on quoting arguments in shell scripts as cp "file.txt" "directory" - and incidentally, there you also need to quote them (both de jure and de facto) when they contain spaces but certainly not for simple identifiers.

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

This is a barel of snakes. 🤦‍♂️ I love your passion and your respectful answer so let's agree to, whatever we just did. I'm 15 years jr to you and perhaps I can't argue with time. But what is idiomatic isn't constant so what is idiomatic today? What is it tomorrow?

As for quotes, sometimes it's as simple as mostly every tool including my editor and linter is going to auto format in such a way, it might be a faff to keep changing that. I will study your post again before jumping to this thread.

Thread Thread
 
rsp profile image
Rafał Pocztarski • Edited

I didn't mean to imply that I am more senior so I must be right. In fact, one could argue that since I've done table layouts and rounded corners with gif borders even before sprite maps then my sense of taste has been destroyed forever.

Of course the idiomatic code changes, and quite quickly at that. I actually like your answer. If you saw my projects where the first thing I do is set up linters with the most strict options turned on and explicit AirBnb style guide and enforce it all in the CI pipeline, then it might turn out that we actually might have much more in common than it might seem.

What I wanted to do with this post is for people to select maybe half of those 24 things that I mentioned, maybe add some other things, get surprised by the result and dig more into the standards. Of course the standards are not everything, that's why we have style guides, but tell me - did you read this HTML and think "Of course this is perfectly valid HTML but it just doesn't follow my preferred style guide"?

Collapse
 
alainvanhout profile image
Alain Van Hout

Indeed. The argument is far too similar to the idea that basic politeness and considerateness is superfluous in human interactions, or for that matter, that wearing clothes when going to work isn't essential. Just because it's technically possible to leave it out, that doesn't mean that it's a good idea.

Collapse
 
darrylhodgins profile image
Darryl Hodgins

Well said.

I tend to value consistency, and there's no reason one can't be consistent by just doing the same thing (using quotes, in this case) every time. Same deal with semicolons in JS, and leaving out curly braces on one-line if blocks. To me, it's just sloppy.

In a similar vein, I have my opinion on the tabs vs. spaces debate (and let's not get into that here), I will lay down my sword so long as there's a .editorconfig in the project. Consistency, consistency, consistency.

Collapse
 
rsp profile image
Rafał Pocztarski

It is not only technically possible, but this is actually what is described by the standard and enforced by the validators. Notice that the W3C validator doesn't even emit warnings for that, let alone errors. Most people that I talk to actually think that quotes are required by the standard (they were in XHTML, see my post, so some people may believe that they still are). No one has actually told me that bare identifiers look naked without quotes like going to work without clothes :) good example. But what I noticed is that people who insist on using quotes at the same time use HTML rarely change & to &amp; in URLs and are much less strict in other aspects. The thing with quotes is very similar like in shell scripts and I never see dd if="file1" of="file2" (in shell scripts that quotes are also needed for values with spaces but are not needed for simple single-word identifiers - just like in HTML).

Thread Thread
 
pavelloz profile image
Paweł Kowalski

Which validator exactly enforces it?

valid

Thread Thread
 
adam_cyclones profile image
Adam Crockett 🌀 • Edited

Can't argue with that, but I can't change because it takes a movement to change the hearts of devopers and you would need an authoity such as a website org dedicated to correcting learned knowledge, such an org should permiate through companies, browser vendors and tooling, creating a linter preset and so on. This article won't be enough. But I'm glad you wrote it.

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

Wfh I don't NEED clothes technically 😅 pajamas work.