To reproduce:

Use default installation of Drupal 6.14, notably, using the Garland theme.

In a custom developed module mymodule.module, add a CSS file mymodule.css:

function mymodule_init() {
  drupal_add_css(drupal_get_path('module', 'mymodule') .'/mymodule.css');
}

In the custom CSS file, you want to have list without any bullet points. (Actually, setting any other list-style-type will also trigger this bug).

ul.mymodule {
  list-style-type: none;
}
ul.mymodule li {
  list-style-type: none;
}

Then output HTML from your module that is a UL list:

<ul class="mymodule">
  <li>This list item should have no bullet point at all.</li>
</ul>

Expected result

A list with no bullet point (or whatever you set with list-style-type).

Actual (wrong) result

The list still has a circle type of bullet point.

The bug is...

...in the default Garland theme, garland/style.css, different types of list markers are set using the background property:

Line 123:
ul li, ul.menu li, .item-list ul li, li.leaf {
  padding: 0 0 .2em 1.5em;
  list-style-type: none;
  list-style-image: none;
  background: transparent url(images/menu-leaf.gif) no-repeat 1px .35em; /* LTR */
}

(There are several others, for other selectors/classes.)

Using the background property for this purpose is very confusing. If I want to set my own bullet type I expect to set it with list-style-type. But doing that will not override the circle set by Garland.

How to correct this

Garland should use list-style-type or list-style-image for setting list bullets (the latter for images) as this is the expected way. background should not be used for this purpose.

Workaround

The desired effect is achieved by also setting background property in mymodule.css:

ul.mymodule {
  list-style-type: none;
}
ul.mymodule li {
  list-style-type: none;
  background: none;
}

Comments

crifi’s picture

Version: 6.14 » 6.x-dev
Category: bug » task

I can't follow your interpretation that this is a bug, because it's all valid CSS.

hingo’s picture

Fair enough. It is valid CSS syntax but I argue it is not semantically correct. Just wanted to point out it is confusing not to use the most common option.

If there is some browser compatibility issue why it is done this way then I understand. If there is no reason why it is the current way, then I'd propose to use list-style-image.

jwilson3’s picture

Version: 6.x-dev » 8.x-dev

In general, there are a lot of annoyances with bulleted lists, but my beef has more to do with how Drupal over-qualifies its CSS -- a totally separate issue.

Someone may want to verify this, as this is only a hunch, based on my experience, but I believe the reason for using background instead of list-style-image is due to the long-standing and (well?) known issues of getting list-style image to line up properly in all browsers. The position of the bullet point on lists is one thing that you really cannot tweak with css in *any* browser (other than setting position inside or outside)... the workaround is obviously to use a background image.

I would categorize this more as a general css WTF, than a Drupal bug. Additionally, if you use any of the popular browsers' in-built code inspectors, and have a basic understanding of CSS inheritance, it is trivially easy to see that the selected LI has a CSS rule that sets a background image, so you need to in fact set background: none; instead of list-style-image:none; or list-style:none; I myself have hit this WTF, but I dont think there is a cross-browser solution for this.

I would mark this closed works as designed, but instead, would leave it open, in case someone wants to add a CSS comment that documents the above:

Eg

/* Use background to position the bullet because list-style-image has cross-browser issues */
jwilson3’s picture

Title: Setting bullet image as background for UL lists is confusing and conflicts with list-style-type: none. » Document usage of background instead of list-style-image for unordered lists
crifi’s picture

Component: Garland theme » CSS

Thank you for your suggestions, jwilson3! Okay, but now this issue doesn't only concerns Garland. ;-)
It should be evaluated in general.

jwilson3’s picture

Good point crifi, forgot about that.

bill richardson’s picture

Status: Active » Closed (cannot reproduce)

Not an issue in Drupal 8