Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Code Double Quotes via HTML Codes

In HTML, What is the preferred way to specify html codes like ", and what is the major differences? For example:

&quot;    <!-- friendly code -->
&#34;     <!-- numerical code -->
&#x22;    <!-- hex code -->

Which one should I use and would it ever be an issue if one of these gets deprecated?

like image 924
H. Ferrence Avatar asked Feb 28 '13 12:02

H. Ferrence


People also ask

What does double quotes mean in HTML?

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>"


3 Answers

There really aren't any differences.

&quot; is processed as &#34; which is the decimal equivalent of &x22; which is the ISO 8859-1 equivalent of ".

The only reason you may be against using &quot; is because it was mistakenly omitted from the HTML 3.2 specification.

Otherwise it all boils down to personal preference.

like image 129
James Donnelly Avatar answered Oct 27 '22 22:10

James Donnelly


Google recommend that you don't use any of them, source.

There is no need to use entity references like &mdash, &rdquo, or &#x263a, 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 "?

like image 39
Andy Avatar answered Oct 27 '22 21:10

Andy


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 &quot;world&quot;"), 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 &quot; 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.

like image 24
Jukka K. Korpela Avatar answered Oct 27 '22 21:10

Jukka K. Korpela