CSS for Web Development

0% completed

Previous
Next
Quiz
Question 1
What does the following selector target?
.container p {
  color: green;
}
A
All <p> elements that are direct children of elements with class "container".
B
All <p> elements that are descendants (at any level) of an element with class "container".
C
Only the first <p> element inside each .container element.
D
Every element inside .container that contains <p> in its name.
Question 2
Given the HTML below, which CSS rule will style only the direct <li> children of the <ul>?
<ul class="menu">
  <li>Home</li>
  <li>About</li>
  <div>
    <li>Subitem</li>
  </div>
</ul>
A
.menu li
B
ul li:first-child
C
.menu > li
D
ul > li:last-child
Question 3
What does the following selector match?
h2 + p {
  margin-top: 0;
}
A
Every <p> element inside an <h2>.
B
Every <p> element immediately preceding an <h2>.
C
All <p> elements that follow any <h2>, not necessarily immediately.
D
The <p> element that immediately follows each <h2>.
Question 4
In the following CSS rule, what elements will be selected?
h2 ~ p {
  color: purple;
}
A
Every <p> element that comes after an <h2> (not just the immediate one) within the same parent.
B
Only the <p> that directly follows each <h2>.
C
All <p> elements that are children of <h2>.
D
Only the first <p> after an <h2>.
Question 5
Which selector would you use to style all <div> elements that follow a <header> element in the same container?
A
header > div
B
header + div
C
header div
D
header ~ div

.....

.....

.....

Like the course? Get enrolled and start learning!
Previous
Next