Jessica sent in the following tutorial request:
Hey Ashley,
I was wonder how you use icons, such as the heart one, in your lists instead of the normal round/square bullet points. I tried using fontawesome and css to change my own lists to stars but I can’t seem to figure it out. Hope you can help.
Thanks,
Jessica
Here’s an example of what she’s referring to, in case you haven’t seen my lists:
- Lorem ipsum dolor sit amet, consectetur adipiscing elit.
- Quisque id est nibh.
- Sed iaculis, lectus id tempor lacinia, massa lacus consequat urna, dictum posuere risus nunc nec metus.
The list HTML
If you’re using a CMS, you probably have a visual editor to create a list. But if not, here’s what the HTML structure looks like:
<ul> <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</li> <li>Quisque id est nibh.</li> <li>Sed iaculis, lectus id tempor lacinia, massa lacus consequat urna, dictum posuere risus nunc nec metus.</li> </ul>
Styling the list
Next, you need to add custom CSS to your theme like this:
ul { list-style: none; } ul li { padding: 5px 0 5px 30px; position: relative; } ul li:before { content: '\f004'; color: #a7dacc; font-family: 'FontAwesome'; position: absolute; top: 6px; left: 5px; }
See where I entered in content: '\f004';
? That’s the code for the Font Awesome heart. You can change this to any other Font Awesome icon. Find your desired icon in the Font Awesome list and click on it. On that page, find where it says:
Unicode: f004
Copy whatever number/letter combination is after unicode and replace f004 with that code. But make sure you keep the \
in front in the code I provided.
So, for example, if you wanted to use the star icon instead, your code would look like this:
content: '\f005';
Want to change the colour?
If you want to change the colour of the icon, just edit this line of code:
color: #a7dacc;
Change the a7dacc
part to another hex colour value. You can use ColorPicker.com to find a colour. Then copy the number/letter combination in the input box at the top (after the #
sign).
This is brilliant, thank you for sharing Ashley!
No problem. π
Thanks for sharing, really useful π love it!
My pleasure!
Can I marry your brain? π
Hmm, not sure how my husband feels about sharing π
Thanks Ashley! I love the way lists look with the icons.
I must be completely stupid, but I have no idea where to add this custom css to my theme? I’ve been manually adding font awesome to each post here and there but to make a custom list, I’m at a loss.
Yep… it’s been confirmed… I’m an idiot! I just found what I was looking for. This is awesome! LOL
You have convinced me that I need to use Font Awesome! π
You make it look so simple! I was totally baffled! Thank you for sharing! π
I used the code you posted, but instead of just changing my lists in my posts, it changes the navigations and the pagination. I tried adding #main to the code, and it no longer affects the navigation, but it still changes the pagination. Do you have any tips on how to fix this? Thanks!
Add
.post_content
before each line of code. πAwesome! Thank you! It worked! I feel so silly!
Ok, I love this idea, but it changes way to many things on my website. Is there a way to limit it so that it only appears for bullets in a review post? It puts them in my menu.
Add
.post_content
before each line of code.like this?
ul .post_content{
list-style: none;
}
ul li.post_content {
padding: 5px 0 5px 30px;
position: relative;
}
ul li.post_content:before {
content: ‘\f0f4 ‘;
color: #5d6b6c;
font-family: ‘FontAwesome’;
position: absolute;
top: 6px;
left: 5px;
}
No, put it before everything, not at the end. So:
I am doing fa-coffee but when I do this the bullets disappear but there is no coffee cup. Hmm, I must be missing a step. I do have your awesome font plugin.
If that’s a new icon it might not be included in the version the plugin is using.
Ok, so if I use the other method you recommended as opposed to the plugin it may work? LOL I didn’t realize not all worked. Although I can make it appear with shortcode and your plugin. Thanks Ashley.
I figured it out..woot!
Don’t ban me from the blog for spamming you..*blushes* If you want to exclude a part of your actual post from converting to image what command would you write? My share buttons which oddly do not have bullet points now have coffee cups. (this happen with menu too until I excluded it and made post content only but need to add a line. I tried Google for the answer but no luck.
(sorry for intruding) Here is a quick fix for that:
.sharedaddy li{
padding: 0 !important;
}
.sharedaddy li:before{
content: none !important;
}
I love this! I wanted to try it, but it didn’t work for me for some reason. I tried with the bolt, but it added it to all the menu options, and in my actual lists it just added it after the bullet itself =/
I keep forgetting to do this on my blog! I did run into a problem with the circle bullet points still showing up. Moving the list-style: none; to the “ul li” instead of just “ul” worked for me.
I’ve finally got around to trying this out, and I was wondering how would you change the bullets for the different list levels? All of the sub-lists now use the same icon, but I’d like them to each be different if possible.
You would use the exact same code but put an extra ul in front of it each time. Example:
This affects all lists
This affects the SECOND LEVEL of lists
To target a deeper level, just keep adding uls (
ul ul ul li:before
).Awesome! Thank so much. π
Ashley, this is so awesome!! And so easy to do! Thanks so much for this. π
You’re super welcome! π
Thank you, this helped solve a problem we had tackled with javascript!
Hi, Ashley. Thanks for the article. I realise it’s quite old, but perhaps you still read the comments.
I find that some codes work, and some don’t. For example, f004 and f005 work. But f001 (musical note) or f21c (motorcycle) don’t.
I’ve downloaded the latest version of Font Awesome.
If you have any time to point out the error of my ways, I’d be grateful!
Thanks – Cath
I took coding years ago in college I was afraid of it then and Iβm still afraid of it now. But I stil yearn to learn how to use it.