'How to use tick / checkmark symbol (✓) instead of bullets in unordered list?
I have a list where I want to add tick symbol before list text. Is there any CSS that can help me to apply this way?
✓ this is my text
✓ this is my text
✓ this is my text
✓ this is my text
✓ this is my text
✓ this is my text
Note: I want this in this type of HTML code
<ul>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
</ul>
Solution 1:[1]
You can use a pseudo-element to insert that character before each list item:
ul {
list-style: none;
}
ul li:before {
content: '?';
}
<ul>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
</ul>
Solution 2:[2]
Here are three different checkmark styles you can use:
ul:first-child li:before { content:"\2713\0020"; } /* OR */
ul:nth-child(2) li:before { content:"\2714\0020"; } /* OR */
ul:last-child li:before { content:"\2611\0020"; }
ul { list-style-type: none; }
<ul>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
</ul>
<ul>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
</ul>
<ul><!-- not working on Stack snippet; check fiddle demo -->
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
</ul>
jsFiddle
References:
Solution 3:[3]
As an addition to the solution:
ul li:before {
content: '?';
}
You can use any SVG icon as the content, such as the Font Aswesome.
ul {
list-style: none;
padding-left: 0;
}
li {
position: relative;
padding-left: 1.5em; /* space to preserve indentation on wrap */
}
li:before {
content: ''; /* placeholder for the SVG */
position: absolute;
left: 0; /* place the SVG at the start of the padding */
width: 1em;
height: 1em;
background: url("data:image/svg+xml;utf8,<?xml version='1.0' encoding='utf-8'?><svg width='18' height='18' viewBox='0 0 1792 1792' xmlns='http://www.w3.org/2000/svg'><path d='M1671 566q0 40-28 68l-724 724-136 136q-28 28-68 28t-68-28l-136-136-362-362q-28-28-28-68t28-68l136-136q28-28 68-28t68 28l294 295 656-657q28-28 68-28t68 28l136 136q28 28 28 68z'/></svg>") no-repeat;
}
<ul>
<li>this is my text</li>
<li>this is my text</li>
<li>This is my text, it's pretty long so it needs to wrap. Note that wrapping preserves the indentation that bullets had!</li>
<li>this is my text</li>
<li>this is my text</li>
</ul>
Note: To solve the wrapping problem that other answers had:
- we reserve 1.5m ems of space at the left of each
<li>
- then position the SVG at the start of that space (
position: absolute; left: 0
)
Here are more Font Awesome black icons.
Check this CODEPEN to see how you can add colors and change their size.
Solution 4:[4]
<ul>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
</ul>
you can use this simple css style
ul {
list-style-type: '\2713';
}
Solution 5:[5]
You could also use ::marker pseudo element to set the marker of your list items.
It's list of allowed CSS properties is somewhat limited, though.
Browser support as of March 2022: 91% (no IE support)
ul li::marker {
content: '?';
color: green;
}
<ul>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
<li>this is my text</li>
</ul>
Solution 6:[6]
Just want to add that for anyone stuck in a unique situation where inline css is necessary (such as within a mass email context where email clients still need inline css) you can use a list-style-type: none and combine it with the character code for your bullet of choice (checkmark used below) like so:
<ul style="list-style-type: none;">
<li>✔ List Item 1</li>
<li>✔ List Item 2</li>
<li>✔ List Item 3</li>
<li>✔ List Item 4</li>
</ul>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Community |
Solution 3 | |
Solution 4 | Hitendra Singh Shekhawat |
Solution 5 | |
Solution 6 | Joel Youngberg |