Welcome to the Treehouse Community
Looking to learn something new?
sam hankins9,372 Points
Can someone explain when I should be using single quotes vs. double quotes?
Trying to figure out why single quotes worked here but double quotes didn't. Any guidance on how to remember that rule of when and where to use witch would be helpful! Thanks! :)
Jason AndersTreehouse Moderator 145,624 Points
You weren't very clear with the question, so I'm guessing when I think you're referring to this line:
If you are, then only single quotes will work because there is a set of double quotes already inside. If you use double quotes, then the interpreter sees an opening - closing - opening - closing set of quotes.
Whenever you have quotes inside of quotes, they cannot be the same unless you escape them.
In short. it doesn't matter which ones go where as long as they are different. So
"<input type='checkbox'/>" would also work.
Hope that was what you were asking. :)
To avoid issues, I always will use double quotes as my default, and then, if I need quotes again within the double quotes, I will use single quotes. This way, I can usually avoid using the escape character.