Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Rendering inconsistency on ul with Firefox being the odd ball out

Tags:

Background

I was creating a secondary navigation menu using embedded unordered lists with anchors and headers. Using a CSS reset sheet all headers and anchors are set to "display: block". When list-style-position: inside is set Firefox and Camino render the headers and anchors below the bullet while Safari, Camino, and IE render it inline.

Example Screen Shots

Firefox and Camino rendering
(source: michaelgrace.org)
Safari, Opera, and IE rendering
(source: michaelgrace.org)

Example Code

<html> <head>   <style type="text/css">     /* css reset */     h1, h2, h3, h4, h5, h6, a { display: block; }      /* list styling */     ul { list-style-position: inside; }   </style> </head> <body> <ul>   <li>     <h3>Primary</h3>     <ul>       <li>         <h4>Secondary</h4>         <ul>           <li>             <h5>Tertiary</h5>             <ul>                       <li><a href="#">Tertiary Link</a></li>             </ul>           </li>         </ul>       </li>     </ul>   </li> <ul> </body> </html> 

To get Firefox and Camino to render the same as the others I set the unordered lists, headers, and links to "display: inline" but I still want to know...

Question

Why does Firefox & Camino render the list item below the list bullet when Safari, Opera, & IE render it "normal"?

like image 935
Mike Grace Avatar asked Jul 17 '09 09:07

Mike Grace


1 Answers

Update

This is actually broken and has been since 2000. Still not fixed. I thought I had figured it out but it was a mistake on my part. STILL BROKEN! :(

Answer

Setting the CSS property of "list-style" to "disc" will cause the Firefox and Camino rendering engine, Gecko, to render the headers inside an unordered list "normal".

Answer Background

After following @o.k.w's advice of digging into the rendering engine I found that my problem had been reported on bugzilla.mozilla.org on April 22, 2000! (*Cough* Um, Mozilla... the bug is still there.) The reported bug at https://bugzilla.mozilla.org/show_bug.cgi?id=36854 discusses the fact that Mozilla's rendering engine, Gecko, has a problem displaying headers in an unordered list while displaying the list item marker inside. It also says about this problem:

"This actually seems to be a major CSS1 compliance issue..." - David Baron

At the bottom of the bug report thread there is a link a w3c.org document that led me to find my fix:

"There is a description in a CSS 2.0 recommendation: http://www.w3.org/TR/CSS2/generate.html#q11 which tell us that Gecko behavior is faulty." - Listy Blaut

At the bottom of that document there is a suggestion to set the CSS list-style to disc:

ul        { list-style: disc } 

Setting the unordered list list-style to "disc" has "fixed" the rendering problem in Gecko rendering engine browsers, Firefox & Camino, while leaving the lists unchanged in other browsers. *Note: Although "disc" is a list-style-type property, if "list-style-type: disc" is used instead of "list-style: disc" it does not fix the problem.

Solution Example Code

<html> <head>     <style type="text/css">         /* css reset */         h1, h2, h3, h4, h5, h6, a { display: block; }          /* list styling */         ul { list-style-position: inside; list-style: disc;}     </style> </head> <body>      <ul>         <li>           <h3>Primary</h3>           <ul>              <li>                 <h4>Secondary</h4>                 <ul>                   <li>                      <h5>Tertiary</h5>                      <ul>                                     <li><a href="#">Tertiary Link</a></li>                      </ul>                   </li>                 </ul>              </li>           </ul>         </li>      <ul> </body> </html> 

How I feel finding the answer to my own question

alt text
(source: michaelgrace.org)

I can finally sleep ; )

like image 74
Mike Grace Avatar answered Jan 03 '23 10:01

Mike Grace