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

Spencer Renfro
PLUS
Spencer Renfro
Courses Plus Student 9,976 Points

How could I use the square bracket attribute selector un place of Guils' code

So in the video Guils' code is:

.col:not(:first-child), nav a:not(:first-child){ margin-left: 15px; }

I was trying to do this part on my own using the attribute selector and I can not get it to work.

col:not(:first-child),
nav:not(:first-child + a[href*='col']){
  margin-left: 15px;
}

I have also tried to comma separate after :first-child

col:not(:first-child),
nav:not(:first-child,  a[href*='col']){
  margin-left: 15px;
}

Just really curious how this code should be written the correct way to get the same result

1 Answer

Steven Parker
Steven Parker
216,891 Points

It looks like you're trying to add an attribute restriction to the original code, so you only need to add the brackets to what was there before, placing them directly after the tag name:

nav a[href*='col']:not(:first-child) {

If that's not it, please be more specific about what behavior you are attempting to create.

Spencer Renfro
Spencer Renfro
Courses Plus Student 9,976 Points

Yes that was exactly what I was trying to do, thank you so much!