In: Computer Science
Use only three context selectors SPACE, >, and +, add document level CSS code to the HTML file below to implement styles required in the body portion of the HTML file.
<body>
<p> Here should be yellow </p> <div>
<p> Here should be cyan </p> <div>
Content of this division should be brown
<p> Some text </p> </div>
<p> Here should be red </p> <p> Here should be green </p> <div>
<p> Here should be brown </p> <div>
<p> Here should be pink </p> </div>
</div> </div>
<p> Here should be blue </p> </body>
2) Use minimal number of selectors, otherwise 10 points deduction will be applied.
1) Only three context selectors specified above can be used. Using other
selectors or other types of CSS code, i.e. inline CSS or external CSS, will
cause 50 points deduction.
Dear Student ,
As per the requirement submitted above , kindly find the below solution.
Here a new web page with name "selectors.html" is created, which contains following code.
selectors.html :
<!DOCTYPE html>
<html lang="en">
<head>
<!-- title for web page -->
<title>Context Selectors</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- style is used for internal style sheet -->
<style>
body p {
color: yellow;
}
/* style for para in div */
div>p {
color: cyan;
}
/* style for color brown */
div>div {
color: brown;
}
/* style for <p> immediately after <p> */
p+p {
color: green;
}
/* style for color blue */
div+p {
color: blue;
}
/* style rule for red color */
div>div+p {
color: red;
}
/* style rule for pink color */
div div div p{
color: pink;
}
/* style for brown color */
div div>p{
color: brown;
}
</style>
</head>
<body>
<p> Here should be yellow </p>
<div>
<p> Here should be cyan </p>
<div>
Content of this division should be brown
<p> Some text </p>
</div>
<p> Here should be red </p>
<p> Here should be green </p>
<div>
<p> Here should be brown </p>
<div>
<p> Here should be pink </p>
</div>
</div>
</div>
<p> Here should be blue </p>
</body>
</html>
======================================================
Output : Open web page selectors.html in the browser and will get the screen as shown below
Screen 1 :selectors.html
NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.