Learn about...
CSS allows many web pages to share a common set of styles, which is perhaps the most simple example of code re-use because it happens outside the complexity of "programming languages." CSS enables websites to be consistent and uniform and allows the appearance to be globally changed in one source document.
Use this activity to answer the Pre-lab Questions. Be sure to complete the activity and answer the pre-lab questions in Blackboard before the start of the lab period.
Note that these instructions are not always detailed. You must figure out some of the details by reading the textbook and investigating online sources. You can always ask your instructor for help. If your instructor is busy helping others, raise your hand to make sure the instructor sees that you need help, but then put your hand down and go back to work. As you wait for help, try your best to solve the problem on your own by reading the textbook.
For the first few labs, I will show you some of the features of Notepad++, which we will use for editing. At home you can use the editor or IDE of your choice. Again, Eclipse and NetBeans are popular ones and I recommend using multiple editors and IDE's to see which one you like the best.
For certain labs, I will show and explain some basics about image editing and Gimp, which we will use for editing images. Gimp is a free and powerful editor, but it is not user friendly. Feel free to experiment with GIMP as I show you how to do common image editing tasks.
You can work together with your partner during lab. But after the lab session is over, you must complete this activity independently. Be sure to email your partner relevant files before the end of the lab session. You should not collaborate with your partner outside of the designated two-hour lab session.
h1
for the page name, h2
for your name, and ol
and li
to format your answers.
margin: 30px;
. Save index.css. Reload anthony_carmelo.html in a browser and make it full screen. How did this change the layout of the article.
Change it back. Centered pages are more common and generally regarded as more appealing.
section
, stats
, and info
. Which one of these is an html element, which one is a class name, and which one is an id name?header, footer {color: #EEF;}
helps you write less code, but there is another perhaps more important reason to style two or more elements with one declaration? Describe the reason.a:hover
and a:focus
. What does a:hover really refer to? In other words, what exactly is being colored red and when does this happen?a:hover {font-size: 5em;}
. Save index.css. Reload anthony_carmelo.html in a browser. Now, move your mouse pointer over the hyperlink. Do you think this visual behavior is annoying? Why or why not?header h2
. What exactly are we styling?header h3
. Change this to just h3
, i.e., remove "header" Save index.css. Reload anthony_carmelo.html in a browser. Notice that the "INFO" header changed. Based on these observations, why is it important to be able specify context?h3
) and player team (h4
) on separate lines, I displayed them on the same line. What CSS property did I change to enable block elements (h3
and h4
) to display on the same line?dt
and dd
elements that float left which allows them to flow from left to right rather than top to bottom. Remove overflow: auto
. Save index.css. Reload anthony_carmelo.html in a browser. How did this change the glossary and why did this happen?ul li
.
What problem would occur if I selected just li
?article#team { width: 1000px; }Note that
article
is a semantic tag that can be used to contain large amounts of content. In this case,
the player page and team page are considered different types of articles. Note that
we could have used a div
tag instead of an article.
section#record, section#leaders, section#ranking { width: 300px; float: right; /* Move it to the right */ clear: right; /* Move it below other items that float right */ }The code above moves three of the five sections to the right in a fixed column (300px width). The next_game and roster sections can now flow up to the top of the page. Giving elements fixed width and then floating them right or left is the most common way to create multi-column layouts. Content is often put in sections or divisions (div) so semantic blocks of content can be moved as a group to create different layouts.
h3
of only the record sectionsection#record h3 { font-size: 1.2em; border-bottom: 1px solid #ccc; margin-top: 24px; }The style sheet makes all the
h3
tags very large (1.8em or 21.6pt) font size and they look too big
when floated to the right in a narrow 300px column. Thus, we reduce the font size to 1.2em or 14.4pt. We also add
a bottom border line and some top margin so the beginning and end of the sections are more obvious.
head
of ny_knicks.html
<style> header, footer { background-color: #0053a0; color: #f36f21; } </style>The code above decorates the header and footer with the Knicks official colors. Think about why we would not add this code to the main style sheet which is used by all the players and teams.
strong
tag in the "next game" section of ny_knicks.html
<strong style="color: #008800">@ Boston</strong>The code above decorates this specific
strong
tag's test is green (color of Boston Celtics).
The strong
tag is used throughout this specific page but we only want to change the color of this one instance.
margin:0px 20px 20px 20px;
. This allows the header to move closer to the table. When margin has 4 parameters they define the top, right, bottom, and left margin (clockwise from top).section#roster h3 { font-family: 'Libre Baskerville', sans-serif; font-size: 1.1em; font-weight: bold; text-align: center; margin: 10px 20px 0px; padding: 10px 0px 5px; background: #eef; background: -webkit-gradient(linear, left top, left bottom, from(#ddf), to(#eef)); background: -moz-linear-gradient(top, #ddf, #eef); border-top-left-radius:5px; border-top-right-radius:5px; }The code above uses styles similar to the table. Alternatively, we could have used a table caption but I wanted to show you how to make an element (h)3 look like it is part of another element (table). Well-designed web pages, have very meaningful semantic HTML markup where the presentation is entirely controlled with CSS.
section#next_game { width: 580px; margin: 20px; padding: 10px 20px; background: #88f; background: -webkit-gradient(linear, left top, right top, from(#88f), to(#eef)); background: -moz-linear-gradient(left, #88f, #eef); border-radius: 10px; overflow: auto; } section#next_game h3 { color: white; margin: 0px; font-size: 1.5em; float: left; } section#next_game span.game { font-size: 1.2em; float: right; }The code above demonstrates many CSS properties worth studying. In particular: width, font-size, margin, padding, color, and float.
Submit in Blackboard a single zip files that contains your entire lab2 folder. Be sure the following files were created.
Important: Make sure these files are in your lab2 folder, so you can zip/compress the entire lab2 folder. Then, submit the zip/archive file.