This lesson describes advanced HTML and CSS definitions, using a fairly complex example to illustrate. Here are some images rendered with HTML and CSS: Here's the HTML for it (the CSS is below): <body> <div class="img"> <a target="_blank" href="klematis_big.htm"> <img src="klematis_small.jpg" alt="Klematis" width="110" height="90" /></a> <div class="desc">Add a description of the image here</div> </div> <div class="img"> <a target="_blank" href="klematis2_big.htm"> <img src="klematis2_small.jpg" alt="Klematis" width="110" height="90" /></a> <div class="desc">Add a description of the image here</div> </div> <div class="img"> <a target="_blank" href="klematis3_big.htm"> <img src="klematis3_small.jpg" alt="Klematis" width="110" height="90" /></a> <div class="desc">Add a description of the image here</div> </div> <div class="img"> <a target="_blank" href="klematis4_big.htm"> <img src="klematis4_small.jpg" alt="Klematis" width="110" height="90" /></a> <div class="desc">Add a description of the image here</div> </div> </body> Here are the important attributes of an <img> element: src alt -- used to specify the text that should appear for browsers that don't show images. width, height -- size of the picture. Can set one or both to 'auto'. Here's some CSS styling examples for the images above (instructor walkthrough of w3c tutorial): div.img { margin: 2px; }border: 1px solid #0000ff; height: auto; width: auto; float: left; text-align: center; The above sample specifies that all divs with class "img" should have the properties listed. The w3c sample used 'img' as a class name-- don't confuse this with the tag 'img'. ColorsColors are generally specified with the rgb form #000000. The first two digits are the red value, the second two the green value, the third the blue value. white black green red purple More example css: div.img img { display: inline; margin: 3px; border: 1px solid #ffffff; }
div.img a:hover img { border: 1px solid #0000ff; } This specifies that within divs of class img, when one hovers over a linked image, change the border. div.desc This specifies the styling for the text below each image.{ text-align: center; font-weight: normal; width: 120px; margin: 2px; } In-Class Assignment1. Go to the following tutorial and play around with modifying the HTML and CSS in the sample:w3c tutorial 2. Create a grid of four images with captions.
|
