Introductions/Icebreaker
Review the Internet (optional)
Review Debugging
HTML and CSS Basics
Validation
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:
Given 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>
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
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;
}
Given boxes.html
, write
boxes.css
to make the appearance on the slide below.
<!DOCTYPE html>
<html>
<head>
<title>Section 4: Boxes Exercise</title>
<link type="text/css" href="boxes.css" rel="stylesheet" />
</head>
<body>
<div id="outer-box">
<div id="inner-box"></div>
</div>
</body>
</html>
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;
}
#outer-box {
background-color: red;
width: 300px;
height: 300px;
padding: 40px;
}
#inner-box {
background-color: yellow;
width: 200px;
height: 200px;
border: 50px solid black;
}
body {
margin: 0;
padding: 0;
}
#outer-box {
background-color: black;
width: 300px;
height: 300px;
border: 50px solid red;
}
#inner-box {
background-color: yellow;
width: 200px;
height: 200px;
margin: 50px;
}
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.borderedFix all of the validation errors in dogs.html
and also
make it match the style guide.
<!DOCTYPE html>
<html>
<head></head>
Dogs are the best!!!
<body>
Why dogs are the best
<li>First of all, they are cute.
<li>Also, they protect against meanies.
<li>Finally, cats SUCK!
Why cats are NOT AS GOOD AS DOGS
They are mean & they scratch.
<h2>Dog pictures:
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Dogs are the Best!</title>
</head>
<body>
Dogs are the best!!!
Why dogs are the best
- Finally, cats SUCK!
Why cats are NOT AS GOOD AS DOGS
They are mean & they scratch.
Dog pictures:
</body>
</html>