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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![stian wilks johansen](https://secure.gravatar.com/avatar/e64f0ad869ab0731e6b351bb45feb02c?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
stian wilks johansen
11,053 Pointscan't get the icons to show
a[href^="http://"] {
color: #52bab3;
text-decoration: none;
background-repeat: no-repeat;
background: 18px 18px;
padding-left: 25px;
}
a[href$=".pdf"] {
background-image: url('../img/icn-pdf.svg');
}
a[href$=".jpg"] {
background-image: url('../img/icn-picture.svg');
}
a[href$=".zip"] {
background-image: url('../img/icn-zip.svg');
}
3 Answers
![Codin - Codesmite](https://uploads.teamtreehouse.com/production/profile-photos/314852/micro_11407067_10153036319003195_4804880150351378114_n.jpg)
Codin - Codesmite
8,600 PointsChange "background: 18px 18px" to "background-size: 18px 18px" as this is a shorthand and not a specific value you are overwriting the background value when you define "background-image:" in the following CSS rules.
a[href^="http://"] {
color: #52bab3;
text-decoration: none;
background-repeat: no-repeat;
background-size: 18px 18px;
padding-left: 25px;
}
a[href$=".pdf"] {
background-image: url('../img/icn-pdf.svg');
}
a[href$=".jpg"] {
background-image: url('../img/icn-picture.svg');
}
a[href$=".zip"] {
background-image: url('../img/icn-zip.svg');
}
Also if your links contain no content or text in your HTML markup the background will not display because the elements width and height would = 0. So if there is no content in the link define the size manually.
Like so:
a[href^="http://"] {
color: #52bab3;
text-decoration: none;
background-repeat: no-repeat;
background-size: 18px 18px;
padding-left: 25px;
height: 18px;
width: 18px;
}
a[href$=".pdf"] {
background-image: url('../img/icn-pdf.svg');
}
a[href$=".jpg"] {
background-image: url('../img/icn-picture.svg');
}
a[href$=".zip"] {
background-image: url('../img/icn-zip.svg');
}
Codepen example: http://codepen.io/anon/pen/RWxqrZ
![heather918](https://secure.gravatar.com/avatar/c63f73d285d3ddb54920b2850346a978?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
heather918
6,375 PointsNot that it was the problem here, but I made the mistake of putting a space between the 'a' and '['. I reviewed my code several times attempting to see where I went wrong, and why my icons wouldn't display. I just wanted to post here in case someone else has a similar issue.
Good: a[href$=".jpg"] {} Bad: a [href$=".jpg"] {}
![Jonathan Grieve](https://uploads.teamtreehouse.com/production/profile-photos/601842/micro_twitterCover.png)
Jonathan Grieve
Treehouse Moderator 91,253 PointsIt's a bit tricky to tell without the HTML code but it could well be you're targeting the wrong classes for the attribute selectors you're using.
$= searches for a string in your href attribute that ends in a particular substring. To get them to match you'd have to use ^=. An attribute selector that looks anywhere in the string for a match.
a[href^=".pdf"] {
background-image: url('../img/icn-pdf.svg');
}
a[href^=".jpg"] {
background-image: url('../img/icn-picture.svg');
}
a[href^=".zip"] {
background-image: url('../img/icn-zip.svg');
Good luck. :-)
![stian wilks johansen](https://secure.gravatar.com/avatar/e64f0ad869ab0731e6b351bb45feb02c?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
stian wilks johansen
11,053 Pointsit was the background size that was wrong :-)
![Jonathan Grieve](https://uploads.teamtreehouse.com/production/profile-photos/601842/micro_twitterCover.png)
Jonathan Grieve
Treehouse Moderator 91,253 PointsCool! Glad you got it sorted :)