Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
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,855 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.