Assignment 10 — Using Divs and Spans
Description: | The <div> and <span> elements provide supporting structure to your web pages. You can use these elements to group things on your web page and to style those items as a group. This assignment also introduces the concept of pseudo-classes. You can use a <div> element to group block-level elements (such as a heading (<h3>) with the related paragraphs or bullet lists). <div id="section_a"> Doing this would allow you to do such things as create a style for that <div> element to create a border around both elements, to specify that the text within that <div> has a specific color, or to provide a background image or color for the <div> element.. For example if you wanted to draw a single box around both the <h3> and <p> element, you could specify the following rule: div#section_a {border-style: dashed; border-width:2px;} The <span> element allows you to do the same type of thing to text within a block-level element. For example, if you wanted, within a single paragraph, to have part of the text in one color and the rest of the text in another color, you could create two <spans> as shown in the following example: <p><span class="menu_item">Hamburger</span> - <span class="price">$5.50</span><p> You could then specify a style rule for each span: span.menu_item {color: green;font-weight: bold;} span.price {color: black;} Certain elements also have a state associated with them. For example, when you display a web page in a browser, often times the visited links (those whose web pages you have already seen) will be a different color than the non-visited links. You can specify these states to have different colors by specifying rules for that state, as shown in the following example. The value link and visited are called pseudo classes, and they are associated automatically with the state of the link as the browser interprets it. a:link {color: purple;} Other states can specified, such as if an element is a first child of a parent element, whether you are hovering a cursor above an, and so on. For more information about <div>, <span>, and elements that support pseudo-class elements, see Chapter 10 of the Head First HTML and CSS book. |
||||||||
HTML elements: |
|
||||||||
CSS properties: |
|
||||||||
Videos: | Introducing Divs and Spans | ||||||||
Tasks: |
|
||||||||
Grading criteria: | Your assignment should demonstrate:
|
||||||||
Due: | By 11/16 |
||||||||
Example assignment: |