Jens Törnell
Jens Törnell

Reputation: 24768

Inherit from root in CSS?

The scenario

Let's say I have a sidebar where every box / widget is an li-element (not very uncommon). I have styled these li-elements with colors, paddings, margins fonts and so on.

One or a few of the boxes have their own inner li-element in their content. I don't want to inherit the styles from the box li element.

Another scenario

Let's say I have a page with main content containg paragraphs, lists and headings added with TinyMCE (an editor).

Then there is a "shortcode" within the content, like this: [my_superbox_module] that is replaced by custom content. That custom content contains boxes added with li-elements.

The code might look like this:

<p>My content</p>
<ul>
    <li>My content list item 1</li>
    <li>My content list item 2</li>
</ul>
<p>Another content</p>
<div class="my_superbox_module">
    <ul>
        <li>My superbox 1</li>
        <li>My superbox 2</li>
    </ul>
</div>
<p>Ending paragraph</p>

In this scenario I don't want to add a class to every ul-element because it is the content part, added with a TinyMCE editor.

Can I inherit from root?

Is there a way to inherit the style properties from root OR just clean it and start from scratch.

These things I know already

Is there a great solid solution for this?

Upvotes: 0

Views: 1923

Answers (1)

kitti
kitti

Reputation: 14814

Why not just use a class? Change your selector in CSS from li to li.sidebar and add class="sidebar" to your li elements.

Upvotes: 2

Related Questions