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 Use Color in CSS

When writing pseudo class inside an element, do we need to put a space? Nick did not put a space between the anchor tag.

In the video, Nick wrote the tag nav a, nav a:visited { color: #fff;} He did not put a space between the <a> and the colon: Will it render a different code if I put a space after the tag, before I write the ":visited" , so then it will be like this ---> nav a, nav a :visited ?

1 Answer

Steven Parker
Steven Parker
231,198 Points

A space in a CSS selector indicates an ancestor/descendant relationship. The rightmost term is the target, and the term on the other side of the space is a parent or further ancestor of the target. Without a space, the selector refers just to the target. For example:

  • nav .here :point_left: targets an element with the class "here" that is inside a nav element
  • nav.here :point_left: targets a nav element that has the class "here"
  • nav a:visited :point_left: targets an "a" element that is in the "visited" state that is inside a nav element

Thank you so much. This makes it clear now