Write the CSS code necessary to recreate the following appearance on-screen, exa
ID: 3912974 • Letter: W
Question
Write the CSS code necessary to recreate the following appearance on-screen,
exactly as shown below.
Not allowed to modify the HTML code.
Need to create a .css file
<div>
<div class="id">A A A A</div>
<div>
<span>B B
B B</span>
<span id="id">C C C C</span>
<span class="class">D D D D</span>
</div>
<div class="class">
<span>E E E E</span>
<div class="id">F F<br />F F</div>
<div id="class">G G<br />G G</div>
<div id="H">H H H H</div>
</div>
</div>
• Text uses Comic Sans MS font at the default size.
• All borders shown are 2px thick and black in color.
• The elements “A” and “F” have yellow background.
• The element “D” has italic text.
• The element “H” is exactly one third (1/3) of the page width, in the page
center; the “H H H H” text appears on the right edge of the element.
Explanation / Answer
Following is the answer:
index.html:
<html>
<head>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div>
<div class="id">A A A A</div>
<div>
<span>B B
B B</span>
<span id="id">C C C C</span>
<span class="class">D D D D</span>
</div>
<div class="class">
<span>E E E E</span>
<div class="id">F F<br />F F</div>
<div id="class">G G<br />G G</div>
<div id="H">H H H H</div>
</div>
</div>
</body>
</html>
style.css
div:first-of-type{
border: 2px solid black;
font-family: "Comic Sans MS";
}
div .id{
border: 2px solid black;
background-color: yellow;
}
span[id=id]{
float: left
}
span[class=class]{
display: block;
font-style: italic;
text-align: right;
}
div[class=class]{
display: block;
clear: right;
border: 2px solid black;
}
div[class=class] span{
float: right;
}
div[class=class] div[class=id]{
border: 2px solid black;
float: left;
background-color: yellow;
}
div[class=class] div[id=class]{
border: 2px solid black;
width: 92.2%
}
div[class=class] div[id=H]{
border: 2px solid black;
margin-left: 33.33%;
width: 33.33%;
text-align: right;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.