Reputation: 7
I'm really new to HTML and CSS and I have just studied nesting where I've got an issue with one of the css challenges for beginners. Here are the challenge requirements:
I was already gives the HTML code and as per the requirements I MUST NOT make any change in it.
div div span {
color: red;
}
div span {
color: blue;
}
p {
color: green;
}
<div class="parent">
<div class="child">This Is Child <span class="title">Title</span></div>
<span class="title">Child Title</span>
<p>Paragraph Content</p>
</div>
<div class="title">Section Title</div>
Kindly assist with number 4. Thank you very much in advance.
Upvotes: 0
Views: 63
Reputation: 10846
Can take note of this CSS for all requirements.
>
= child selector
~
= sibling selector
,
= comma represents styles for both elements separately
.parent>.child>span {
color: red;
}
.parent>.child~.title {
color: blue;
}
.parent>p,
.title {
color: green;
}
<div class="parent">
<div class="child">This Is Child <span class="title">Title</span></div>
<span class="title">Child Title</span>
<p>Paragraph Content</p>
</div>
<div class="title">Section Title</div>
Upvotes: 2
Reputation: 7
Change your CSS to
div div span {
color: red;
}
div span {
color: blue;
}
p {
color: green;
}div {
color: green;
}
Upvotes: -1