Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS The Selectors Solution

Amy Howard
seal-mask
.a{fill-rule:evenodd;}techdegree
Amy Howard
Front End Web Development Techdegree Student 1,807 Points

Are 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
Lukas Pscheidt
2,229 Points

Hi 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
Steven Parker
215,357 Points

Quotes are also interchangeable in JS:

<a href='#' onclick='alert("Clicked");'>Click me!</a>
Steven Parker
Steven Parker
215,357 Points

The 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. :wink:

Amy Howard
seal-mask
.a{fill-rule:evenodd;}techdegree
Amy Howard
Front End Web Development Techdegree Student 1,807 Points

Thanks 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
Steven Parker
215,357 Points

Clicking 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.