Sunday, April 3, 2011

Applying square bullets in css affects numbers

When I use this in my css to achieve square bullets:

li { list-style-type: square; }

it affects all numbered lists as well, as they both use <li>

The context is within a sharepoint richhtmlfield control.

Is there a way around this or have Microsoft not implemented numbered lists correctly?

From stackoverflow
  • You can specify the parent of the <li>s to apply the styles to, thus only affecting unordered lists (<ul>):

    ul li { list-style-type: square; }
    
    Ms2ger : That won't work with an ol inside a ul. I'd suggest using ul {}.
  • I don't know how well you can control the HTML from sharepoint, but..

    If you use <ol> for the ordered and <ul> for the squared lists, you could just use

    ul li {list-style-type: square;}
    

    If you use <ol> for both, you'll have to give the squared list a class eg.

    <ol class="un_ordered"><li>first item</li></ol>
    

    and to css

    .un_ordered li {list-style-type: squared;}
    

0 comments:

Post a Comment