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 Introduction to HTML and CSS (2016) Getting Familiar with HTML and CSS Building Web Pages with HTML and CSS

CSS class calling

***** HTML ****

      <img src="images/me.png" alt="Drawing of Jane Smith" class="profile-image">
      <h1 class="tag name">Hello, I'm Michael.</h1>
      <p class="tag location">My home is Sagay, Negros Occidental.</p>

***** CSS *****

header .profile-image {
  margin-top: 50px;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 3px solid white;
  transition: all .5s;
header .profile-image:hover {
  transform: scale(1.2) rotate(5deg);
.tag {
  background-color: #e2e2e2;
  color: black;
  padding: 10px;
  border-radius: 5px;
  display: table;
  margin: 10px auto;

In this example (.tag) class is under the header as well, but why is there no header in front when calling in CSS? The (.profile-image) is called with a header. What is the difference?

1 Answer

Rohald van Merode
Rohald van Merode
Treehouse Staff

Great question Carl Michael Libo-on!

In this example it would work either way. Main purpose of adding the header element to the selector is that you'll ensure that only .profile-image elements that are nested inside the header will get the styling applied to it. If you would have a different section on the page that also has a .profile-image element this element won't have the same styles applied to it. If you however would remove the header from your selector it will be applied to all the elements on the page with the profile-image-class.

Hope this clears things up 🙂

Now it makes sense to me. Thanks :)