Quiz: Markup, Selectors, Layout
Part 1: Markup
- Circle the markup that would definitely throw a validation error (i.e. you know it’s wrong without needing to see the context in which it appears):
<a id="home link" href="home.html">Home</a>
<li class="item" id="item">A gallon of milk</li>
<h1><strong>My Page<h1></strong>
<img src="photo.jpg" />
<a class="outbound-link news" href="http://nyt.com">New York Times</a>
<h2>Welcome to this <span>Site</span></h2>
Part 2: Selectors
Suppose the following markup appears on a page:
<body>
<div id="wrap">
<h1>My awesome page</h1>
<ul id="nav"> <li><a href="index.html">Home</a></li> <li><a href="work.html">Work</a></li> <li><a href="about.html">About</a></li> </ul>
<div id="main"> <p>My name is Joe. I love design.</p> <p>When not working for the <span class="caps">CIA</span>, I do <a href="work.html">design work</a>.</p> </div> <!-- /main -->
<div id="sidebar"> <h2>Useful Links</h2> <ul> <li><a href="http://joeschmoe.com">Joe Schmoe</a></li> <li><a href="http://pentagram.com">Pentagram</a></li> <li class="edu"><a href="http://watkins.edu">Watkins</a></li> </ul> </div> <!-- /sidebar -->
</div> <!-- /wrap -->
</body>
- Circle the CSS selector(s) that would successfully target the hyperlinks inside the navigation list and no other links on the page.
ul a
#nav li a
ul li a
ul#nav a
- What CSS rule(s) would successfully render “CIA” in small caps?
span#caps {letter-spacing:1px; font:.9em;}
span.caps {letter-spacing:1px; text-size:.9em;}
#caps {letter-spacing:1px; size:.9em;}
.caps {letter-spacing:1px; font-size:90%;}
- Circle the CSS declaration(s) that would successfully add top and right margins of 10px each to the targeted element.
margin:0 10px;
margin:10px 10px 0 0;
margin-top:10px; margin-right:10px;
margin:10px 0;
- Circle the CSS rule(s) that would successfully add a gray background to the unordered list in the sidebar and inset the text from its edges (so that you can see gray all around the text).
#sidebar ul {background-color:gray; padding:10px;}
ul#sidebar {background-color:gray; padding:10px;}
#sidebar h2 ul {background-color:gray; padding:10px;}
ul #sidebar {background-color:gray; margin:10px;}
Part 3: Layout
Let’s say we want to make main
a 400px-wide column on the left and a 300px-wide sidebar
to its right, with everything sitting on a gray background.
- Circle the CSS rule(s) that would successfully put the “Useful Links” all on a single row, next to each other.
#sidebar ul {list-style:none; float:left;}
#sidebar li {float:left;}
ul#sidebar ul {list-style:none;}
ul#sidebar li {display:inline;}
ul .sidebar {list-style:none; float:left;}
ul .sidebar li {float:left;}
.sidebar {list-style:none;}
ul li.sidebar {display:inline;}
- Circle the rules that — working together — would achieve this layout using the “Opposing Floats” technique.
#wrap {width:700px; background-color:gray;}
div#wrap {width:700px; float:left; background-color:gray;}
div .wrap {width:400px; background-color:gray;}
#main {width:400px; float:left;}
.main {width:400px; float:right;}
#sidebar {width:300px; float:right;}
.sidebar div {width:300px; float:right;}