1 CSS Syntax Sample Configure a Web page to display blue text and yellow background. body { color:...
-
date post
21-Dec-2015 -
Category
Documents
-
view
215 -
download
1
Transcript of 1 CSS Syntax Sample Configure a Web page to display blue text and yellow background. body { color:...
1
CSSSyntax 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; }
2
Configuring Color with Inline CSS (1)
Inline CSS 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>
3
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>
4
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>
Configuring Text with CSS
CSS properties for configuring text: font-weight
Configures the boldness of text font-style
Configures text to an italic style font-size
Configures 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;}
8
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.
9
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 © 2009</div>
10
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.
11
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>
Using anExternal Style Sheet
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" />
body { background-color: #0000FF; color: #FFFFFF;}
External Style Sheet color.css
Centering Page Content with CSS#container { margin-left: auto;
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; }
24
Types of Graphics
Graphic types commonly used on Web pages: GIF JPG PNG
25
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
26
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
27
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
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
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;
}
trilliumbullet.gif:
31
OrganizingYour Site
<img src=“images/home.gif” alt=“Home” height=“100” width=“200”/>
• Place images in their own folder
• Code the path to the file in the src atttribute
32
ImageMaps
<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
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" />
34
Overall Design Is Related to the Site Purpose
Consider the target audienceof these sites.
35
Web SiteOrganization
Hierarchical Linear Random
(sometimes called Web Organization)
36
HierarchicalOrganization
A clearly defined home page
Navigation links to major site sections
Often used for commercial and corporate Web sites
37
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 short-term memory
Many web designers try not to place more than nine major navigation links on a page or in a well-defined page area.
38
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.
39
LinearOrganization
A series of pages that provide a tutorial, tour, or presentation.
Sequential viewing
40
RandomOrganization
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.
41
Web Site NavigationBest 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
42
Web Site NavigationBest 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.
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/index-flash.html
DHTML: https://www.weber.edu/
44
Web Site NavigationBest 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
45
Design Principles
Repetition Repeat visual elements
throughout design Contrast
Add visual excitement and draw attention
Proximity Group related items
Alignment Align elements to create
visual unity
46
Web Page DesignBest Practices
Page layout design Text design Graphic design Accessibility considerations
47
Web Page DesignLoad Time
Watch the load time of your pages
Try to limit web page document and associated media to under 60K on the home page
48
Web Page DesignTarget Audience
Design for your target audience Appropriate reading level of text Appropriate use of color Appropriate use of animation
49
Web Page DesignColors & Animation
Use colors and animation that appeal to your target audience Kids
Bright, colorful, tons of animation
Generation X,Y,Z,etc. Dark, often low contrast, more subtle animation
Everyone: 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
50
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
51
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
Wireframe
A sketch of blueprint of a Web page
Shows the structure of the basic page elements, including: Logo Navigation Content Footer
53
Web Page DesignPage 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.
54
Web Page DesignPage Layout(2)
Better
Best
Columns make the page more interesting and it’s easier to read this way.
Columns of different widths interspersed with graphics and headings create the most interesting, easy to read page.
55
Text DesignBest Practices
Avoid long blocks of text Use bullet points Use short paragraphs
56
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
57
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)
58
Graphic DesignBest 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.
59
Graphic DesignRecommended 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