Forum Moderators: open

Message Too Old, No Replies

character entity for quotation marks

when to use " vs "

         

J64sqs

11:15 pm on Nov 6, 2004 (gmt 0)

10+ Year Member



I know you enlose attribute values in quotation marks. But when do you use the character entity, "?

I thought you use " when you have a quotation mark you want to be visible on your page. For example:
<p>
&quot;Eighty percent of success is showing up.&quot; - Woody Allen
</p>

However, the w3c validator will let you get away with just using regular quotation marks:
<p>
"Eighty percent of success is showing up." - Woody Allen
</p>

So, my question is, "which one is right?" And if either is good, then why bother having a character entity to symbolize a quotation mark?

mstk

11:43 pm on Nov 6, 2004 (gmt 0)

10+ Year Member



I'm not sure, but it may have something to do with JavaScript or VBscript, with quotes closing certain commands (but that can be easily bypassed)

encyclo

12:03 am on Nov 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It depends on your charset: IIRC ascii doesn't have the quote mark in it, so you would have to use the character entity
&quot;
. However, if you are using ISO-8859-1 or your own language's charset (and virtually everyone is), you're usually fine with the standard quote mark.

J64sqs

1:23 pm on Nov 7, 2004 (gmt 0)

10+ Year Member



Thanks encyclo.

I'm actually starting to use UTF-8, and I'm guessing it includes the double quote as it contains more characters than ISO-8859-1.

bird

1:34 pm on Nov 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As far as I know, every character set in current use includes the standard double quotes, so that can't be a good reason to use &quot;.

The only place I can think of where it is indeed required is within attribute value strings, which should be delimited by the quotes. One example is the URL string in a link:

<a href="http://www.example.com/an/url/with/a/&quot;/char.html">

If you don't use the &quot; within that string, then the parser will assume that the URL ends at the point where it finds the ".