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

HTML How to Make a Website Customizing Colors and Fonts Write Hexadecimal Colors

Sarah Morris
Sarah Morris
7,161 Points

To set the color of paragraphs in CSS, do you need to put "p { ...}" or just " { ...}" ?

When setting the color of paragraphs in CSS, do you need to specify something like:

body { color: #000; }

or can it just be:

{ color: #000; }

css/main.css
a {
  text-decoration: none;
}

#wrapper {
  max-width: 940px;
  margin: 0 auto;
}

#logo {
  text-align: center;
  margin: 0;
}

h1, h2 {
  color: #fff; 
}

 {
  color: #000; 
}

2 Answers

You always need something before the curly brackets, otherwise the web browser won't know what to apply the styles to.

Inside the curly brackets are the styles you want to apply. Outside the brackets is the element (or elements) you want to apply the styles to.

To apply styles to a paragraph, you'd select the p element, then add your styles inside the curly brackets. For example:

p {
  color: red;
  font-size: 16px;
}

You can apply styles to ALL elements by using the * selector. You won't need to use this very often though:

* {
  background-color: red;
}

There's lots of CSS courses in the treehouse library. Checkout the CSS Basics course for a good starting point.

Hope this helps :)

Sarah Morris
Sarah Morris
7,161 Points

Thanks! Makes way more sense now!

Shane Oliver
Shane Oliver
19,977 Points

P is the paragraph element so you would use the p selector

p { color: #000; }