I want to simulate tabs such that the first word in a list entry always gets a fixed width. I do it like this:
<style>
.tabbed { float: left; width: 5em; }
</style>
<ul>
<li><span class='tabbed'>first</span> entry in my list</li>
<li><span class='tabbed'>second</span> list entry</li>
</ul>
the approach works relatively well except that if I want to do:
li { color: blue }
it applies the color (not surprisingly) to the <li> but not to the <span>. this means that I would have to:
.tabbed { color: blue }
which is not very DRY. In my case I’ve got a whole bunch of declarations for different classes of the list items so it’s cumbersome and ugly.
how does one deal with this?
By default the the
spanshould be colored blue if theliis colored blue.See http://jsfiddle.net/Q2UGE/ for an example
I think you must have some other CSS overriding it
In case you do have something else overriding it that you cant change, you can also enforce
li .tabbedto inherit from it parentSee http://jsfiddle.net/Q2UGE/1/ for an example of that