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 CSS Foundations Text, Fonts, and Lists List Styles

Gavin Broekema
Gavin Broekema
Full Stack JavaScript Techdegree Student 22,443 Points


<!DOCTYPE html>
<link rel="stylesheet" href="style.css" />
<h1>List Properties</h1>
<li>Viverra rutrum orci lacinia iaculis mi per fermentum tortor malesuada</li>
<li>Id aliquam nisi accumsan felis pretium enim arcu fames</li>
<li>Eros mollis sociosqu condimentum lectus cursus pellentesque et laoreet</li>
<li>Rhoncus donec vulputate malesuada euismod nunc conubia netus, ante eros</li>
<li>Sodales ante duis semper nisi malesuada senectus, sed magna odio at egestas</li>
<li>Iaculis porta erat turpis aptent vehicula metus sagittis eleifend ultrices diam maecenas habitasse</li>
<li>Amet nulla aliquam urna faucibus blandit cras id vehicula faucibus, auctor vivamus mattis integer elementum scelerisque faucibus</li>
<li>Duis nullam accumsan conubia auctor aliquam posuere nam tortor mollis a</li>
<li>Duis at posuere rutrum fermentum est, nec ultrices sagittis amet torquent placerat, sit senectus vitae sem</li>
<li>Amet platea facilisis pretium hendrerit nisi aenean curabitur iaculis dictumst, class mi lacus ullamcorper at odio ullamcorper curabitur</li>
body {
width: 80%;
margin: 2.5em auto;
font: 1.1em/1.3 sans-serif;

/* List Styles
--------------------------------------------- */

ul, ol {
  margin-bottom: 2.5em;
  list-style-position: inside;

ul {
  list-style-type: none;

ul li {
  background: url('marker.png') no-repeat 0 2px;
  padding-left: 35px;

ol {
  list-style-type: decimal-leading-zero;
  list-style: decimal-leading-zero outside;

li {
  margin-bottom: 1.2em;

Wouldn't a more effective method for doing this be using the ::before pseudo-element to append the image as a child of the <li> element? I was watching this video through just praying that Guil was going to bust out the ::before pseudo-element, but instead he set the image as the background of the ul li and added padding ):

Also, if I were to try and use ::before to achieve this effect, how would I go about styling it in a similar fashion?

1 Answer

Steven Parker
Steven Parker
230,248 Points

It's not too different. Instead of the rule with the background and padding, you could have something like this:

ul li::before {
  content: url('marker.png');
  margin-right: 10px;

Offhand, I can't think of any advantage of one method or the other.