Using CSS, how can I set a character like "►" as a list marker for an HTML list?
The ::marker CSS pseudo-element selects the marker box of a list item, which typically contains a bullet or number. It works on any element or pseudo-element set to display: list-item , such as the <li> and <summary> elements.
The list-style-type property specifies the type of list item marker.
list-style-type: It is used to specify the type of list-item marker in a list. list-style-position: It is used to specify the position of the list-item markers.
To create an unordered list with square bullets, we will use CSS list-style-type: square property. The list-style-type property in CSS specifies the appearance of the list item marker (such as a disc, character, or custom counter style).
Use the hex value of the desired character in CSS like this:
ul li:before {
content: "\25BA"; /* hex of your actual character, found using CharMap */
}
Note: this will not work in IE < 8
Demo: http://jsfiddle.net/mrchief/5yKBq/
To add a space after the bullet: content: "\25BA" " ";
Demo
You can also use an image like this:
ul {
list-style: disc url(bullet.gif) inside;
}
Also, if you need this in IE<8, you can use the following expression:
UL LI:before,
UL LI .before {
content: "►"
/* Other styles for this pseudo-element */
}
/* Expression for IE (use in conditional comments)*/
UL LI {
list-style:none;
behavior: expression(
function(t){
t.insertAdjacentHTML('afterBegin','<span class="before">►</span>');
t.runtimeStyle.behavior = 'none';
}(this)
);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With