How to Style Bullet Colors in HTML Lists
Q: How can I change the color of the bullets in an unsorted HTML list without using images or span tags?
A: Here's an elegant solution using CSS:
ul { list-style: none; padding: 0; margin: 0; } li { padding-left: 1em; text-indent: -.7em; } li::before { content: "• "; color: red; /* or whatever color you prefer */ }
HTML:
<ul> <li>Foo</li> <li>Bar</li> <li>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</li> </ul>
This gives you square bullets with a red color, without the use of any images or spam tags.
The above is the detailed content of How to Change HTML List Bullet Colors Using Only CSS?. For more information, please follow other related articles on the PHP Chinese website!