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?
What is the difference between double and single quotes?
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.
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:
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.
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'" |
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.'"
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.'"
Don't forget about:
| Code: |
|
<img src="someimage.gif" alt="this image is "smart"" /> |
Thank you very much for your answers. I really appreciate your help.
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
Cheers,
fuzzy
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!
I'm pretty sure they're safe now, but I've developed a double quote habit anyways, just to be sure!
