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 trial

CSS

Cory Davis
Cory Davis
1,208 Points

Is there a reason to use single quotes (') vs. double quotes (") when using the attribute selector?

He does both in the video.

For example, is there any difference between:

input[type='submit']:active { background-color: red; }

AND

input[type="submit"]:active { background-color: red; }

?

3 Answers

Steven Parker
Steven Parker
231,261 Points

Both styles of quotes work the same, but they need to be used in matched pairs.

I used to use single quotes, then later read double quotes were the norm. I view Treehouse as the gold standard of development - the instructor used single quotes ...

Is single quotes preferred?

Steven Parker
Steven Parker
231,261 Points

The only "best practice" is to be consistent with whichever you choose, there's no preference for one style over the other.

Thanks Steven! It'd be easier if one was preferred, lol.

Steven Parker
Steven Parker
231,261 Points

Well, Google's style guide recommends apostrophes (single quotes) for CSS.