HTML Code:
<!DOCTYPE html><!-- Document type declaration -->
<html><!-- Opening HTML tag -->
<head><!-- Head section containing metadata -->
<meta charset="utf-8"><!-- Character encoding declaration -->
<title>HTML CSS Exercises - Adjacent sibling selectors</title><!-- Title of the HTML document -->
<style type="text/css"> /* Opening style tag for CSS with type attribute */
h2 + h3 { /* Adjacent sibling selector targeting h3 elements that directly follow h2 elements */
border-bottom:1px solid silver; /* Add a bottom border to selected h3 elements */
}
</style><!-- Closing style tag -->
</head><!-- Closing head tag -->
<body><!-- Body section of the HTML document -->
<h2>This is heading Two </h2><!-- h2 element with text content -->
<h3>This is heading Three </h3><!-- h3 element with text content -->
<p>This is a paragraph</p><!-- Paragraph element -->
<h3>This is heading Three again</h3><!-- h3 element with text content -->
<p>This is a paragraph again</p><!-- Paragraph element -->
</body><!-- Closing body tag -->
</html><!-- Closing HTML tag -->
Explanation:
Live Demo :
See the Pen adjacent-sibling-selectors-answer by w3resource (@w3resource) on CodePen.
Supported browser
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4