FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

What is the difference between double and single quotes?

 


liangzou
What is the difference between double and single quotes in HTML. Should I use single quote or double quote? In perl, they are different, but I am not sure if they are the same in HTML?
badai
you can use both of them. it's the same. you can even use them like foo='"' or foo="'" so that you will have no problem to have both of them in your var.
cr3ativ3
Well one of the benefits of single quotes is that say, you were giving an item an alt attribute and the alt attribute needed to have quotes in it you could using single quotes in it because double would confuse the script into thinking you had finished the alt attributes value.

For exampe:

Code:

<img src="someimage.gif" alt="this image is "smart"" />


The first double quote encasing the word smart would tell the script that that is the end of the alt attribute which would be a problem so a refined script using single quotes would work better.

Code:

<img src="someimage.gif" alt="this image is 'smart'"
Manus et Therion
In writing, a double quote is just a quote.

For example: John said, "There's no bread in the kitchen."

A single quote is intended to be used within a double quote, a quote of a quote is what it signifies.

For example: John said, "I was with Linda today and she said, 'Terry ate all the rye bread.'"
Aredon
Don't forget about:
Code:

<img src="someimage.gif" alt="this image is &quot;smart&quot;" />
liangzou
Thank you very much for your answers. I really appreciate your help.
Fuzzy-Duck
Just be careful when combining single and double quotes though!! I've lost count of the times I've been plagued for hours and hours on end by pages not displaying how I'd like them to, or code that just fails miserably, only to discover at 3 in the morning, it's all the fault of a rogue single quote where a double should be!! Or vice versa of course...

Cheers,
fuzzy
riv_
Some of the older, more obscure browsers didn't recognize single quotes.
I'm pretty sure they're safe now, but I've developed a double quote habit anyways, just to be sure! Wink
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.