Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

proper CSS for generating a checkmark li that works cross-browser

I'm using the following CSS to add checkmarks before my <li>list items:

ul.checkmark li:before {     content:"\2713\0020"; } 

And then in the HTML:

<ul class="checkmark">    <li>Learn the keyboard at your own pace</li> </ul> 

Works great in Safari, Firefox and Chrome, but displays "freak out boxes" on IE8.

Safari: alt text

IE8:alt text

Is there a portable way to specify a good-looking checkmark that will work in all the major browsers?

EDIT Solution: I ended up using a variation on meder's answer below:

ul.checkmark li {     background:url("../checkmark.gif") no-repeat 0 50%;     padding-left: 20px; }  ul.checkmark {     list-style-type: none; } 
like image 411
George Armhold Avatar asked Nov 27 '10 17:11

George Armhold


People also ask

How do I make a checkmark in CSS?

A checkmark icon can be created with CSS by following these steps : Taking a container element, and using its ::before and ::after pseudo-elements to create two straight lines. Rotate both pseudo-elements to make the element look like a checkmark.

How do I make a checkmark in HTML?

In the web page's HTML source code, add one of the following Unicode HTML entities, depending on the type of check mark you want to insert. &#9745; - inserts the " ☑ " symbol. &#10003; - adds the " ✓ " symbol. &#10004; - inserts the " ✔ " symbol.

What is UL LI A in CSS?

The <ul> tag defines an unordered (bulleted) list. Use the <ul> tag together with the <li> tag to create unordered lists. Tip: Use CSS to style lists. Tip: For ordered lists, use the <ol> tag.

What is Li CSS?

The <li> tag defines a list item. The <li> tag is used inside ordered lists(<ol>), unordered lists (<ul>), and in menu lists (<menu>). In <ul> and <menu>, the list items will usually be displayed with bullet points. In <ol>, the list items will usually be displayed with numbers or letters. Tip: Use CSS to style lists.


2 Answers

li { background:url(/images/checkmark.gif) no-repeat 0 50%; } 

Would probably be the only way you'll get it to work consistently in the IE pre 8/9.

like image 143
meder omuraliev Avatar answered Sep 29 '22 04:09

meder omuraliev


ul {     list-style-image:url("/default_unchecked.png");     /* other list styles*/  } 

then later change it via javascript, maybe.

$('.selected').css("list-style-image", "url('/images/blueball.gif')"); 
like image 37
Robin Maben Avatar answered Sep 29 '22 05:09

Robin Maben