Welcome to WEB 150!

Download Report

Transcript Welcome to WEB 150!

CSS
Syntax Sample
Configure a Web page to display blue text and
yellow background.
body { color: blue;
background-color: yellow; }
This could also be written using hexadecimal
color values as shown below.
body { color: #0000FF;
background-color: #FFFF00; }
1

Inline CSS




Configuring Color with
Inline CSS (1)
Configured in the body of the Web page
Use the style attribute of an XHTML tag
Apply only to the specific element
The Style Attribute

Value: one or more style declaration property and value
pairs
Example: configure red color text in an <h1> element:
<h1 style="color:#ff0000">Heading text is red</h1>
2
Configuring Color with
Inline CSS (2)
Example 2: configure the red text in the heading
configure a gray backgroundin the heading
Separate style rule declarations with ;
<h1 style="color:#FF0000;background-color:#cccccc">This is
displayed as a red heading with gray background</h1>
3
CSS Embedded Styles






Configured in the header section of a Web page.
Use the XHTML <style> element
Apply to the entire Web page document
Style declarations are contained between the
opening and closing <style> tags
The type attribute indicates the MIME type of
text/css
Example: Configure a Web page with white text
on a black background
<style type ="text/css">
body { background-color: #000000;
color: #FFFFFF;
}
</style>
4
Configuring Text with CSS

CSS properties for configuring text:

font-weight
 Configures

font-style
 Configures

text to an italic style
font-size
 Configures

the boldness of text
the size of the text
font-family
 Configures
the font typeface of the text
The font-size Property

Accessibility Recommendation:

Use em or percentage font sizes – these can be easily
enlarged in all browsers by users
The font-family Property


Not everyone has the same fonts installed in their
computer
Configure a list of fonts and include a generic family
name
p {font-family: Arial,Verdana, sans-serif;}
XHTML
<div> element


A block-level element
Purpose: configure a specially formatted division or
area of a Web page



There is a line break before and after the division.
Can contain other block-level and inline elements
Useful to define an area that will contain other
block-level tags (such as paragraphs or spans)
within it.
8
XHTML
<div> Element Example


Configure a page footer area
Embedded CSS:
<style type="text/css">
.footer { font-size: small;
text-align: center; }
</style>
XHTML:
<div class=“footer">Copyright &copy; 2009</div>

9
XHTML
<span> element


An inline-level element
Purpose:


configure a specially formatted area displayed
in-line with other elements, such as within a
paragraph.
There is no line break before and after the
span.
10
XHTML
<span> Element Example

Embedded CSS:
<style type="text/css">
.companyname { font-weight: bold;
font-family: Georgia, "Times New Roman", serif;
font-size: 1.25em;
}
</style>

XHTML:
<p>Your needs are important to us at <span
class=“companyname">Acme Web Design</span>.
We will work with you to build your Web site.</p>
11
Using an
External Style Sheet
External Style Sheet color.css
body { background-color: #0000FF;
color: #FFFFFF;
}
To link to the external style sheet called color.css, the
XHTML code placed in the header section is:
<link rel="stylesheet" href="color.css" type="text/css" />
Centering Page Content
#container { margin-left: auto;
with CSS
margin-right: auto;
width:80%; }
CSS Troubleshooting Tips


Verify you are using the : and ; symbols in the right spots—
they are easy to confuse.
Check that you are not using = signs instead of : between
each property and its value.

Verify that the { and } symbols are properly placed

Check the syntax of your selectors, their properties, and
property values for correct usage.

If part of your CSS works, and part doesn’t:



Review your CSS
Determine the first rule that is not applied.
Often the error is in the rule above the rule that is not applied.
Validate your CSS at http://jigsaw.w3.org/css-validator
The CSS border Property

Configures a border on the top, right,
bottom, and left sides of an element

Consists of



border-width
border-style
border-color
h2 { border: 2px solid #ff0000 }
CSS Borders:
Block / Inline Elements

Block element


default width of element content extends to
browser margin (or specified width)
Inline element

Border closely outlines the element content
h2 { border: 2px solid #ff0000; }
a { border: 2px solid #ff0000; }
Browser Display Can Vary
Configuring Specific
Sides of a Border

Use CSS to configure a line on one or more
sides of an element




border-bottom
border-left
border-right
border-top
h2 { border-bottom: 2px solid #ff0000 }
The CSS padding Property

Configures empty space between the
content of the XHTML element and the
border

Set to 0px by default
h2 { border: 2px solid #ff0000;
padding: 5px; }
No padding configured:
Configuring Padding on
Specific Sides of an Element

Use CSS to configure padding on one or
more sides of an element




padding-bottom
padding-left
padding-right
padding-top
h2 { border: 2px solid #ff0000;
background-color: #cccccc;
padding-left: 5px;
padding-bottom: 10px;
padding-top: 10px;}
CSS padding Property
Shorthand: two values

Two numeric values or percentages


first value configures top and bottom padding
the second value configures left and right padding
h2 { border: 2px solid #ff0000;
background-color: #cccccc;
padding: 20px 10px;
}
CSS padding Property
Shorthand: four values

Four numeric values or percentages

Configure top, right, bottom, and left padding
h2 { border: 2px solid #ff0000;
width: 250px;
background-color: #cccccc;
padding: 30px 10px 5px 20px;
}
Hands-On Practice
h1 { background-color:#191970;
color:#E6E6FA;
padding: 15px;
font-family: Georgia, "Times New Roman", serif; }
h2 { background-color:#AEAED4;
color:#191970;
font-family: Georgia, "Times New Roman", serif;
border-bottom: 2px dashed #191970; }
Types of
Graphics

Graphic types commonly used on
Web pages:
GIF
 JPG
 PNG

24
GIF







Graphics Interchange Format
Best used for line art and logos
Maximum of 256 colors
One color can be configured as transparent
Can be animated
Uses lossless compression
Can be interlaced
25
JPEG







Joint Photographic Experts Group
Best used for photographs
Up to 16.7 million colors
Use lossy compression
Cannot be animated
Cannot be made
transparent
Progressive JPEG – similar to interlaced
display
26
PNG







Portable Network Graphic
Support millions of colors
Support multiple levels of transparency
(but browsers do not -so limit to one transparent color for Web display)
Support interlacing
Use lossless compression
Combines the best of GIF & JPEG
Browser support is growing
27
CSS background-image
Property


Configures a background-image
By default, background images tile (repeat)
body { background-image: url(background1.gif); }
CSS background-repeat Property
Using background-repeat
trilliumbullet.gif:
h2 { background-color: #d5edb3;
color: #5c743d;
font-family: Georgia, "Times New Roman", serif;
padding-left: 30px;
background-image: url(trilliumbullet.gif);
background-repeat: no-repeat;
}
Organizing
Your Site
• Place images in
their own folder
• Code the path to
the file in the src
atttribute
<img src=“images/home.gif” alt=“Home”
height=“100” width=“200”/>
31
Image
Maps

<map> element


Defines the map
<area> element
Defines a specific area on a map
 Can be set to a rectangle, circle, or
polygon

 href
Attibute
 shape Attribute
 coords Attribute
32
Sample
Image Map
<map name="boat" id="boat">
<area href="http://boat.com" shape="rect"
coords="24, 188, 339, 283" alt=“fishing boat" />
</map>
<img src="boat.jpg" usemap="#boat" alt=“Lake Michigan"
width="416" height="350" />
Overall Design Is Related
to the Site Purpose
Consider the
target audience
of these sites.
34
Web Site
Organization
Hierarchical
 Linear
 Random

(sometimes called Web Organization)
35
Hierarchical
Organization
A clearly defined
home page
 Navigation links to
major site sections
 Often used for
commercial and
corporate Web sites

36
Hierarchical
Too Shallow

Be careful that the organization is not too shallow.


Too many choices  a confusing and less usable web site
Information Chunking

“seven plus or minus two” principle


George A. Miller found that humans can store only five to nine chunks of information at a time in shortterm memory
Many web designers try not to place more than nine major navigation
links on a page or in a well-defined page area.
37
Hierarchical
Too Deep

Be careful that the organization
is not too deep.

This results in many “clicks”
needed to drill down to the
needed page.

User Interface “Three Click Rule”

A web page visitor should be able to
get from any page on your site to any
other page on your site with a
maximum of three hyperlinks.
38
Linear
Organization


A series of pages that provide a tutorial,
tour, or presentation.
Sequential viewing
39
Random
Organization

Sometimes called
“Web” Organization

Usually there is no
clear path through
the site

May be used with
artistic or concept
sites

Not typically used for
commercial sites.
40
Web Site Navigation
Best Practices(1)

Make your site easy to navigate




Provide clearly labeled navigation in the same
location on each page
Most common – across top or down left side
Provide “breadcrumb” navigation
Types of Navigation



Graphics-based
Text-based
Interactive Navigation Technologies




Image Roll-overs
Java Applet
Flash
DHTML fly-out or dropdown menus
41
Web Site Navigation
Best Practices(2)

Accessibility Tip

Provide plain text links in the page
footer when the main navigation is
non-text media such as images,
Flash, Java Applet or DHTML.
42
http://www.fdic.gov/consumers/consumer/alerts/
Text Based Navigation: http://www.usdoj.gov/
Graphic Based Navigation: http://www.dot.gov/index.cfm
Flash Navigation: http://www.loc.gov/wiseguide/sept08/indexflash.html
DHTML: https://www.weber.edu/
Web Site Navigation
Best Practices(3)

Use a Table of Contents (with links to other
parts of the page) for long pages.

Consider breaking long pages in to multiple
shorter pages using Linear Organization.

Large sites may benefit from a site map or site
search feature
44
Design Principles

Repetition


Contrast


Add visual excitement and
draw attention
Proximity


Repeat visual elements
throughout design
Group related items
Alignment

Align elements to create visual
unity
45
Web Page Design
Best Practices
Page layout design
 Text design
 Graphic design
 Accessibility considerations

46
Web Page Design
Load Time

Watch the load time
of your pages

Try to limit web page
document and
associated media to
under 60K on the
home page
47
Web Page Design
Target Audience

Design for your target audience
Appropriate reading level of text
 Appropriate use of color
 Appropriate use of animation

48
Web Page Design
Colors & Animation

Use colors and animation that appeal to
your target audience

Kids


Generation X,Y,Z,etc.


Dark, often low contrast, more subtle animation
Everyone:




Bright, colorful, tons of animation
Good contrast between background and text
Easy to read
Avoid animation if it makes the page load too slowly
Accessibility Tip: Many individuals are unable
to distinguish between certain colors.

See http://www.vischeck.com/showme.shtml
49
Web Page Design
Browser Compatibility

Web pages do NOT look the same in all
the major browsers

Test with current and recent versions of:





Internet Explorer
Firefox, Mozilla
Opera
Mac versions
Design to look best in one browser and degrade
gracefully (look OK) in others
50
Web Page Design
Screen Resolution

Test at various screen resolutions


Most widely used: 1024x768, 1280x1024, and
800x600
Design to look good at various screen
resolutions


Centered page content
Set to either a fixed or percentage width
51
Wireframe
A sketch of blueprint of a Web page
 Shows the structure of the basic page
elements, including:

Logo
 Navigation
 Content
 Footer

Web Page Design
Page Layout(1)



Place the most important information
"above the fold"
Use adequate "white" or blank space
Use an interesting page layout
This is usable,
but a little
boring. See the
next slide for
improvements
in page layout.
53
Web Page Design
Page Layout(2)
Better
Columns make the
page more interesting
and it’s easier to read
this way.
Best
Columns of different widths
interspersed with graphics and
headings create the most
interesting, easy to read page.
54
Text Design
Best Practices
Avoid long blocks of text
 Use bullet points
 Use short paragraphs

55
Text Design
“Easy to Read” Text (1)

Use common fonts:


Arial, Helvetica, Verdana, Times New Roman
Use appropriate text size:

medium, 1em, 16px, 12 pt, 100

Use strong contrast between text &
background

Use columns instead of wide areas of
horizontal text
56
Text Design
“Easy to Read” Text (2)

Bold text as needed

Avoid “click here”

Hyperlink key words or phrases, not entire
sentences

Separate text with “white space” or
empty space.

Chek yur spellin (Check your spelling)
57
Graphic Design
Best Practices(1)

Be careful with large graphics!

Remember 60k recommendation

Use the alt attribute to supply descriptive
alternate text

Be sure your message gets across even if
images are not displayed.


If using images for navigation provide plain text links at
the bottom of the page.
Use animation only if it makes the page
more effective and provide a text
description.
58
Graphic Design
Recommended Practices(2)

Choose colors on the web palette if consistency
across older Windows/Mac platforms is needed

Use anti-aliased text in images

Use only necessary images

Reuse images

Goal: image file size should be as small as possible
59