Images & Tables
Three graphic file types are supported by today's browsers: GIF - Graphic Interchange Format JPEG - Joint Photographic Experts Group PNG - Portable Network Graphics Image file formats
GIF GIF files are best used for images that have broad areas of flat color and are highly defined. Supports transparency and animation Supports a maximum of 256 colors. Guidelines to keep GIF files small: Reduce the number of colors Crop out extra space if possible
GIF
Problem?
JPEG Solution
JPG JPEG files are best used for images that require many colors such as photographs. JPEG has a higher compression ratio but it is a "lossy" compression (compression sacrifices some image data in reducing file size).
PNG PNG was developed as an alternative to GIF Does not yet have broad-based browser or image editor support. Has a lot of the same features as GIF PNG also automatically adjusts graphics for gamma correction to compensate for cross- platform differences in brightness and contrast. Does not support animation
Inserting images on your pages: Image tag We usually put images in a separate folder on the web server. The image file has a 644 permission Example: The source attribute (src) refers to the name and location of the image file relatively to the HTML file itself.
Image tag attributes height: specifies the height of the image. width: specifies the width of the image. border: determines the size of the border. alt: specifies the text displayed on-screen when the cursor is rolled over the image. Always use this! align: puts the image to the right or left of the screen. valign: align text associated with the image at the top, middle, or bottom wrt the image.
Aligning Images To align an image left: Using CSS (the tag): img {float: left} Both of these will cause text to appear to the right of the image and wrap around it.
Aligning Images NOTE: Most browsers do not support To align an image center:
Image Borders Line that appears around a picture (like a frame). Will appear automatically when you use an image as a link. Where # is between 0 and 99
Linking from an Image Place the tag inside the anchor tag.
Some images This pic caption shows up at the bottom <img src = “Images/flowers.jpg " width=“100” height=“50” alt=“Flowers” align=“right” border=“3”> Hyperlinked picture: Example Caption for an image Affect image size Add border
Image as page background sets the background image. Using the new standard (within tag): body {background-image: url(../jpg/bgd/stucco1.jpg)} Image Size: A large image may only appear once (depending on the size of the browser window) Smaller images will be tiled as many times as necessary to fill a page.
HTML and Colors Colors in HTML documents are represented by a triplet of numbers, called an RGB triplet, based on their Red, Green, and Blue component.Ex: RED = (255,0,0) HTML requires that the color values be entered as 3 two-digits hexadecimal numbers. Ex: RED = FF0000 digit1 digit2 digit3 digit4 digit5 digit6 red green blue There are many online charts and references for color. Or just click on Color Chart from our Important Documents page.
Color as attribute of Body Tag Text color Background color New standard (within tag): body {background-color: Ivory; color: Navy}
Hyperlink has 4 states: link: unvisited links vlink: visited links hover: mouse hover over link alink: a hyperlink that the user is thinking of visiting (the user has moused over and depressed the mouse button on). Hyperlink colors:
More links about Color: HTML Colors: HEX RGB color code converter: Background/Text color selector
Tables
Basic HTML Tables A table organizes data in rows and columns … Enclose the table structure … Table row … Each data cell within a row. The smallest area of a table that can be formated. This controls the number of columns in the table.
Basic table structure A1 A2 A3 B1 B2 B3 A1A2A3 B1B2B3 First row First Column
The HTML for the basic table structure
attributes border="# pixels"> Size of the border around the table cellspacing ="# pixels"> space inserted between cells cellpadding ="# pixels"> size of the gap between the cell text and the cell border align = "left/right"> table is placed on the left/right and text is wrapped around the table "center"> table is placed in the center of the page. Text is not wrapped around the table
More Attributes bordercolor="color"> changes the color of the border. bordercolordark="color"> bordercolorlight="color"> creates a 3D effect for the border.
More attributes frame="box|above|below|void" …> controls which side of the table has borders
More attributes rules="all|rows|cols|none"> controls around which cell the border is drawn.
,, attributes width="pixels" or "%"> table/cell width in pixels or as % of the page/table. height="pixels" or "%"> Same as above. bgcolor="color"> Change the table/cell background color. background=“pic.jpg”> Tiles a picture as a background.
Question Given a table specified with: with the first three cells in the first row coded as: 9 A.M. 12 P.M. What is the width of the last column in the above table?
Cell attributes (, ) colspan="#" this cell spans across # columns. rowspan="#" this cell spans over # rows. align= valign= "left/right"> text in the cell is aligned left/right. "center"> text in the cell is centered. "top/bottom"> text in the cell is aligned top/bottom. "middle"> text in the cell is aligned with the middle of the cell.
Summary - Table Level Attributes <table width="n" pixels or "n%" percentage align="left", "center", "right“ bgcolor="hex value“ border="pixels“ bordercolor="hex value“ cellspacing="pixels“ cellpadding="pixels" >
Summary - Row Level Attributes <tr align="left", "center", "right“ valign="top", "bottom", "middle" bgcolor="hex value” >
Summary - Cell Level Attributes <td align="left", "center", "right“ valign="top", "bottom", "middle“ bgcolor="hex value“ height="n" pixels or "n%" percentage width="n" pixels or "n%" percentage rowspan="n" rows to span colspan="n" columns to span >
Question Here is a table: What additional coding will make it look like this?
Tables are very commonly used for webpage design layout To display content in newspaper-like columns or separates the page in different topical areas. Start with the outer table and work your way in using nested tables. Add background color to visually separate column. Add cell padding to avoid crowding. Use row spanning to vary the starting point of articles.
Example: A progression toward the desired design One Table Adding an Image Nesting Tables