In HTML, What is the preferred way to specify html codes like "
, and what is the major differences? For example:
" <!-- friendly code -->
" <!-- numerical code -->
" <!-- hex code -->
Which one should I use and would it ever be an issue if one of these gets deprecated?
For example in Java the double quote is used to indicate the start and end of a String, so if you want to include a doublequote within the String you have to escape it with a backslash. String s = "<a href=\"link\">a Link</a>"
There really aren't any differences.
"
is processed as "
which is the decimal equivalent of &x22;
which is the ISO 8859-1 equivalent of "
.
The only reason you may be against using "
is because it was mistakenly omitted from the HTML 3.2 specification.
Otherwise it all boils down to personal preference.
Google recommend that you don't use any of them, source.
There is no need to use entity references like
&mdash
,&rdquo
, or☺
, assuming the same encoding (UTF-8) is used for files and editors as well as among teams.
Is there a reason you can't simply use "
?
There is no difference, in browsers that you can find in the wild these days (that is, excluding things like Netscape 1 that you might find in a museum). There is no reason to suspect that any of them would be deprecated ever, especially since they are all valid in XML, in HTML 4.01, and in HTML5 CR.
There is no reason to use any of them, as opposite to using the Ascii quotation mark (") directly, except in the very special case where you have an attribute value enclosed in such marks and you would like to use the mark inside the value (e.g., title="Hello "world""
), and even then, there are almost always better options (like title='Hello "word"'
or title="Hello “word”"
.
If you want to use “smart” quotation marks instead, then it’s a different question, and none of the constructs has anything to do with them. Some people expect notations like "
to produce “smart” quotes, but it is easy to see that they don’t; the notations unambiguously denote the Ascii quote ("), as used in computer languages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With