0

I want to add specific style property on all child elements of this .feature-section-heading class. I know i can do that using below trick

.feature-section-heading > h1 {...}

But above logic will implement on just h1 tag. So is there possible that i can add style property on all child elements? I searched about that and find accepted answer, but it does not work.

Community
  • 1
  • 1
Ayaz Ali Shah
  • 3,305
  • 8
  • 35
  • 64
  • `.feature-section-heading > * {...}` would apply the style to all immediate children (but there may be a better way to achieve what you are trying to do). The universal selector, `*` is not considered efficient css. What is it that you are trying to apply? – ne1410s Feb 01 '16 at 12:49
  • this was asked previously http://stackoverflow.com/questions/26349987/how-do-i-apply-a-style-to-all-children-of-an-elements – lacexd Feb 01 '16 at 15:22

5 Answers5

2

CSS

.feature-section-heading > * {...}

You can use the * as all element selector.

Dirk Jan
  • 2,197
  • 3
  • 16
  • 33
2

Use a universal selector instead of a type selector.

.feature-section-heading > *
Quentin
  • 857,932
  • 118
  • 1,152
  • 1,264
1

You Can use * (Asterik Selector)

Here is the Demo

CSS

.foo *{background:red}

HTML

<div class="foo">

<span>1</span>
<p>2</p>
<div>3</div>

</div>
Dinesh Kanivu
  • 2,494
  • 1
  • 21
  • 53
0

Access All childrens with Css * selector as in code snippet below:

.feature-section-heading > * {
    background: red;
}
Andriy Ivaneyko
  • 18,421
  • 4
  • 52
  • 73
0

Please find the jsfiddle link that illustrates the desired behavior.

HTML

<div class="feature-section-heading">
    I am parent div
    <br />
    <h1>
        Heading
    </h1>
    <div>
        Child DIV
    </div>
    <div>
        Child DIV
    </div>
    <p>
        Child paragraph
    </p>
    <p>
        Child paragraph
    </p>
    <p>
        Child paragraph
    </p>
    <span>
        Child span
    </span>
</div>

CSS

.feature-section-heading {
  color: red;
}
.feature-section-heading > :not(:empty){
    color: darkgreen;
}
Shashank
  • 2,004
  • 2
  • 14
  • 38