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

Dorota Parzych
Dorota Parzych
5,706 Points

May I choose certain "a:link"s?

I would like to select certain anchors (ex. from the header) not all "a:link"s and display them as blocks. Is it possible? If yes then how can I do that? Thanks in advance!

1 Answer

There is several ways of doing this.

For example, if they're all in the header, you can do

.header a:link {
   display: block;
}

This will target only the links that are a descendant of header.

If they're intended as navigational links (like a menu), you can wrap them in the semantic html tag nav. In which case you can target them with

nav a:link {
  display: block;
}

you can of course also give them their own class in which case you simply target that class.