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! While you're at it, check out some resources Treehouse students have shared here.
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 trialAmy Howard
Front End Web Development Techdegree Student 1,807 PointsAre single and double quotation marks used interchangeably in CSS?
In the solutions video for the CSS Selectors workshop the following code was given: at 1:39 input[type='submit'] at 1:54 input[type="text"]
Are the single and double quotation marks interchangeable?
Thanks!
4 Answers
Lukas Pscheidt
2,229 PointsHi Amy Howard
There is no difference between single or double quotes. You can simply use single quotes or double quotes, that is simply up to you, but my recommendation is to use double quotes. Especially when you will want to add some JS, you will find it very useful.
Here is example how I write code:
<a href="#" onclick="alert('Clicked');">Click me!</a>
EDIT: Thanks Steven Parker, I forgot to say, that quotes are interchangeable. But what i said, using single or double quotes is up to you.
So you can write code also:
<a href='#' onclick='alert("Clicked");'>Click me!</a>
Steven Parker
231,236 PointsThe quote types are interchangeable, as long as they are used in matching pairs.
But it is a good practice to use one type consistently. Some style guides indicate a preference for one or the other, usually double quote (").
Google style guide recommends double quotes (") for HTML, and single(') for CSS. But then they're not totally consistent with that even in their own documentation.
Amy Howard
Front End Web Development Techdegree Student 1,807 PointsThanks to you both! Do either of you know how to access the "markdown cheatsheet" referenced at the bottom of this page? The link takes me to the main dashboard of the community, but I don't see it mentioned there...
Steven Parker
231,236 PointsClicking on the Markdown Cheatsheet below the "Add an Answer" area should not take you to another page, it should open a modal pop-up window. But here's a link to a page with even more information: Markdown Basics.
You may also want to watch this video on code formatting.
Amy Howard
Front End Web Development Techdegree Student 1,807 PointsThank you, Steven!
Steven Parker
231,236 PointsSteven Parker
231,236 PointsQuotes are also interchangeable in JS:
<a href='#' onclick='alert("Clicked");'>Click me!</a>