Review CSE 154 development tools
Write CSS with HTML
Review CSS selectors
By the end of this section, you should be able to:
Recall: How to Use Firefox Page Inspector and Chrome Web Inspector
Firefox and Chrome both have built-in web inspectors that you can use on any web page. Firefox's Page Inspector is a Firefox add-on that lets you dynamically examine or modify the content and styling of web pages. To use it, right-click any page element and selector "Inspect Element". The Chrome Web Inspector tool behaves the same way, and comes conveniently built-in with Chrome. You can launch both by hitting F12 while in your browser.
Use Firefox or Chrome to inspect the course web site:
Directions: Use the given HTML code and CSS selector tool on the slide below to improve your skills in CSS selectors!
Write a CSS selector here for:
h2
elementsintro
h2
elements inside intro
h2
elements, except those inside intro
p
elements inside content
p
elements directly inside content
bordered
h2
elements with class bordered
h2
elementsh2intro
#introh2
elements inside intro
#intro
h2h2
elements, except those inside intro
#content h2, #footer h2p
elements inside content
#content pp
elements directly inside content
#content > pbordered
.borderedh2
elements with class bordered
h2.borderedGiven the following HTML, what CSS would be necessary to produce the expected output below? (You can download the HTML here and the corgi image here).
<h2>CSS: Corgis, Short & Sweet</h2>
HTML
output
Assume that the corgi image (background image of the h2
tag)
is located in the directory '../../img/corgi.gif'
, is positioned 520px
from the left edge of the h2
, and has a background size
of 60px x 60px
in the output. The "CSS" text is green and
the "Sweet" text is purple. Any text that is not green/purple has a
color of #444
. The "short" text is all lower-case and has
a font-size of 14pt. The word "Sweet" is italicized, and both
"Sweet" and "Corgis" have a cursive font type. Note: you may add
<span>
tags as appropriate to get the desired
output.
One possible solution is provided below:
CSS: Corgis, Short &
Sweet
HTML
h2 {
/* background: bg-image bg-repeat bg-position/bg-size */
background: url("../../img/corgi.gif") no-repeat 520px/60px;
color: #444;
}
#css-abbr { color: green; }
#short, #sweet { font-family: cursive; }
#short {
font-size: 14pt;
text-transform: lowercase;
}
#sweet {
color: purple;
font-style: italic;
}
CSS
Given boxes.html
, write
boxes.css
to make the appearance below.
output
The outer border of the box is red, the inner border of the box is black, and the inner background color of the box is yellow. Both the outer and inner borders have a width of 50 pixels. The yellow portion of the box has a width and height of 200 pixels. The overall box has a width and height of 400 pixels.
Two possible solutions are provided below (there are more possible):
body {
margin: 0;
padding: 0;
}
#inner-box {
background-color: yellow;
border: 50px solid black;
height: 200px;
width: 200px;
}
#outer-box {
background-color: red;
height: 300px;
padding: 50px;
width: 300px;
}
CSS
body {
margin: 0;
padding: 0;
}
#inner-box {
background-color: yellow;
height: 200px;
margin: 50px;
width: 200px;
}
#outer-box {
background-color: black;
border: 50px solid red;
height: 300px;
width: 300px;
}
CSS