How to display a plus sign (+) in a
CSS How to Display a Plus Sign (+) in a
- List Style
In this article, we’ll explain how to display a plus sign (+) in a <li>
list style.
Read more: CSS Tutorial
Using the ::before pseudo-element
You can use the ::before
pseudo-element to add a plus sign (+) icon. Set the content
property to the plus sign (+) character, and then adjust the position and style using style settings.
li::before {
content: "+";
display: inline-block;
padding-right: 5px;
}
In the code above, we use the ::before
pseudo-element to add a plus sign (+) character and display it before the list item content by setting the display
property to inline-block
. We also set the padding-right
property to adjust the spacing between the plus sign and the list item content.
Here’s an example:
<ul>
<li>List Item 1</li>
<li>List Item 2</li>
<li>List Item 3</li>
</ul>
After applying the above CSS styles, the list items will appear as shown below:
-
- List Item 1
-
- List Item 2
-
- List Item 3
Using a Custom Icon Font
Instead of using the plus sign character, we can also use the plus sign icon from a custom icon font to achieve the same effect.
First, we need to include our custom icon font. This can be achieved by using the @font-face
rule and importing the font file from a third-party service.
@font-face {
font-family: "Custom Icons";
src: url("path/to/custom-icons.woff") format("woff");
}
li::before {
font-family: "Custom Icons";
content: "