Summary
Double quotes are used because at the beginning of the tagging language ( SGML ), authors could do use of special characters (which were sometimes difficult to enter, if not impossible through the keyboard) just by typing your reference, p. eg:
-
"<"
represents the% sign <
.
-
"&gt;"
represents the% sign >
.
-
"&quot;"
represents the% sign "
.
-
"&#229;"
(in decimal) represents the letter a
with a small circle on it.
- Among others ...
In a nutshell, like some programming languages, they enjoyed rich functionality compared to single quotes.
Source: W3C - HTML4 .
Explanation
The official document of the W3C (on HTML5 syntax) mark that it is perfectly correct the use of the attribute-value pair with single quotes, double quotes or even with absence of quotation marks; Clear! each with certain rules.
Value of the attribute without quotes
The name of the attribute, followed by one or more space characters, followed by a single character U + 300D EQUAL SIGN, followed by one or more space characters, followed by the value of the attribute, which , in addition to the requirements provided ..., you must dispense with any literal space character , of any U + 0022 QUOTATION MARK (single quotes), U + 0027 APOSTROPHE (apostrophe), U + 003D EQUALS SIGN (equal sign), U + 003C LESS-THAN SIGN (less than), U + 003E GREATER-THAN SIGN (greater than) or U + 0060 GRAVE ACCENT (grave accent), and should not be an empty string.
Value of the attribute with single quotes
The name of the attribute, followed by one or more space characters, followed by a single character U + 300D EQUAL SIGN (equal sign), followed by one or more space characters, followed by U + 0027 APOSTROPHE (apostrophe ), followed by the value of the attribute, which, in addition to the requirements provided ..., must dispense with any character of U + 0027 APOSTROPHE (literal apostrophe) and finally followed by another U + 0027 APOSTROPHE (apostrophe).
Value of the attribute with double quotes
The name of the attribute, followed by one or more space characters, followed by a single character U + 300D EQUAL SIGN (equals sign), followed by one or more space characters, followed by U + 0022 QUOTATION MARK ( English quote), followed by the value of the attribute, which, in addition to the requirements provided ..., must dispense with any character of U + 0022 QUOTATION MARK (English quote) and finally followed by another U + 0022 QUOTATION MARK (English quote ).
Derived from all this (and probably the custom) the W3C uses in its examples double quotes or without quotes, it is for convenience and sometimes good practices to promote the same thing that the official documentation urges you to do based on your examples, do the opposite It's like trying to cut down a tree, going against the grain of the wood.