Vitphire
Vitphire

Reputation: 75

CSS element>element selector in style attibute

Can this code be replicated using the style attribute?

<style>
#red-paragraphs > p {
color:red;
}
</style>

<div id="red-paragraphs">
<p>red paragraph</p>
<p>another red paragraph</p>
</div>

<div>
<p>not red paragraph</p>
</div>

Somehow like this:

<div style="????????">
<p>red paragraph</p>
<p>another red paragraph</p>
</div>

<div>
<p>not red paragraph</p>
</div>

I would only be using the style once, and I would like to change the file where the change is being done.

Upvotes: 0

Views: 43

Answers (1)

Weilory
Weilory

Reputation: 3121

with a reference to HTML Style Attribute

<div style="color: red;opacity: 0.5;">
<p>red paragraph</p>
<p>another red paragraph</p>
</div>

<div>
<p>not red paragraph</p>
</div>

inline styling does not support child selecting inheritance since that's what CSS made for. you can only do this:

<div>
  <p style="color: red;opacity: 0.5;">red paragraph</p>
  <p style="color: red;opacity: 0.5;">another red paragraph</p>
</div>

<div>
  <p>not red paragraph</p>
</div>

Upvotes: 1

Related Questions