In HTML, the list-style-type property is used to specify the bullet style for list items. However, it doesn't natively support dashes as bullet characters.
One approach to create a dash-style list is to use the :before pseudo class. This allows you to insert content before each list item and style it independently.
<code class="css">ul.dashed { list-style-type: none; } ul.dashed > li::before { content: "-"; margin-right: 5px; }</code>
The content property inserts the dash "-" before each li, and margin-right provides some space between the dash and the list item text.
To maintain the indented list effect while using the :before pseudo class, you can apply negative text-indent to the list items.
<code class="css">ul.dashed > li { text-indent: -5px; }</code>
This counteracts the default indentation created by bullet styling, aligning the dash with the start of the list item text.
To use a generic character as a list bullet, you can simply specify it in the list-style-type property, such as:
<code class="css">ul.generic { list-style-type: disc; } ul.square { list-style-type: square; } ul.circle { list-style-type: circle; }</code>
This allows you to create lists with different bullet shapes and customize the visual appearance of your lists as needed.
The above is the detailed content of How to Create Dash-Styled Lists in HTML: Beyond the Default Bullet Styles?. For more information, please follow other related articles on the PHP Chinese website!