Upload
a-vd
View
1.225
Download
2
Embed Size (px)
DESCRIPTION
Citation preview
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 1
Some More About You
Median Rank
HTML CSS Javascript PhP MySQL Design SEO Mobile Apps
4
3
2 2 2 2
1 1
n = 37
A Message From The Dean
Recap
• Introductions • Class Objectives• XAMPP Review• Stuff about WWW & HTML• HTML Crash Course sections
– Introduction to HTML– How to code a Web Page (partial)
Agenda
• Continue HTML Crash Course sections– How to code a Web Page– How to code tables
• CSS Crash Course sections– Introduction to CSS– How to work with CSS– How to code selectors– How to work with text & lists
Some stuff about Today
• We will build and style Mike’s Bait & Tackle shop web app (pages 173-7) – Home page: index.html – About us page: about.html
• You will need to use 2 image files emailed to you. – face.jpg– star.gif
• For homework you will (1) refactor CSS code and create separate external link and (2) you will apply CSS styling to table in about.html in same file
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 7
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 8
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 9
Murach’s JavaScript, C4 © 2009, Mike Murach & Associates, Inc.Slide 10
*Updates for this class
• XHMTL rules supersede by HTML5 and will be noted where appropriate
Murach’s JavaScript, C4 © 2009, Mike Murach & Associates, Inc.Slide 11
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc. Slide 12
Murach’s JavaScript, C4 © 2009, Mike Murach & Associates, Inc.Slide 13
Tags that create lists
Tag Description
<ul> Creates an unordered list.
<ol> Creates an ordered list.
<li> Creates a list item for an unordered or ordered list.
<dl> Creates a definition list. It contains pairs of <dt> and <dd> tags.
<dt> Creates a term in a definition list.
<dd> Creates a definition in a definition list that’s indented.
Murach’s JavaScript, C4 © 2009, Mike Murach & Associates, Inc.Slide 14
Examples of list tags <ul> <li>Unordered List</li> <li>Ordered List</li> <li>Definition List</li> </ul> <ol> <li>XHTML</li> <li>CSS</li> <li>JavaScript</li> </ol> <dl> <dt>Local Area Network</dt> <dd>A network of computers directly connected to each other.</dd> <dt>Wide Area Network</dt> <dd>A network of LANs connected by routers.</dd> </dl>
Murach’s JavaScript, C4 © 2009, Mike Murach & Associates, Inc.Slide 15
The lists in a web browser
A little more about Lists1. Go to a breakfast meeting.2. Get a haircut at lunch.3. Go shopping after work and
buy:• French’s Frogs’ Legs• Spamburger Helper• Chemical Cola• Bucket of Lowfat Lard
<ol> <li>Go to a breakfast meeting.</li> <li>Get a haircut at lunch.</li> <li>Go shopping after work and buy: <ul> <li>French's Frogs' Legs</li> <li>Spamburger Helper</li> <li>Chemical Cola</li>
<li>Bucket of Lowfat Lard</li> </ul> </li> </ol>
Exercise #2
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 18
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc. Slide 19
Murach’s JavaScript, C4 © 2009, Mike Murach & Associates, Inc.Slide 20
Common XHTML character entities
Entity Character
& &
< <
> >
© ©
® ®
™ ™
¢ ¢
° º
± ±
A non-breaking space that will always be displayed.
Murach’s JavaScript, C4 © 2009, Mike Murach & Associates, Inc.Slide 21
Exercise #3
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 23
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 24
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 25
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc. Slide 26
Murach’s JavaScript, C4 © 2009, Mike Murach & Associates, Inc.Slide 27
Attributes of the <a> tag
Attribute Description
href Specifies the URL for a link.
target Specifies where the destination document should be loaded.
name Creates an anchor within a web page.
Murach’s JavaScript, C4 © 2009, Mike Murach & Associates, Inc.Slide 28
Murach’s JavaScript, C4 © 2009, Mike Murach & Associates, Inc.Slide 29
Murach’s JavaScript, C4 © 2009, Mike Murach & Associates, Inc.Slide 30
The <a> tags in a web browser
More on Document Relative Links
Creating hyperlinks from sourcepage.html to other pages in the site when Destination page is in the same directory folder as source page
<a href="page1.html">Go To Page 1</a>
Document-relative links use directions from the source page to the destination page.
Adapted from MediaCollege.com
More on Document Relative Links
Creating hyperlinks from sourcepage.html to other pages in the site when Destination page is in a folder inside the source page's folder
<a href="directory2/page2.html">Go To Page 2</a>
Document-relative links use directions from the source page to the destination page.
Adapted from MediaCollege.com
More on Document Relative Links
Creating hyperlinks from sourcepage.html to other pages in the site when destination page is in a folder outside the source page's folder using special instruction (../)
<a href="../directory3/page3.html">Go To Page 3</a>
<a href="../../index.html">Go To The Index Page</a>
Document-relative links use directions from the source page to the destination page.
Adapted from MediaCollege.com
Site-Root Relative Links
The link begins at the same level as your domain (mysite.com) and works down the path <a href="/main-directory/directory4/page4.html">Go To Page 4</a>
Site-root-relative links use a single forward-slash ( / ) to signify the instruction
Adapted from MediaCollege.com
Exercise #4
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 36
Q: What type of link are these?
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 37
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc. Slide 38
Murach’s JavaScript, C4 © 2009, Mike Murach & Associates, Inc.Slide 39
Attributes of the <img> tag
Attribute Description
src The URL of the image to display.
alt Alternate text to display in place of the image. This text is read aloud by screen readers.
longdesc A long description of the image.
height The height to use for the image in pixels or a percentage.
width The width to use for the image in pixels or a percentage.
Murach’s JavaScript, C4 © 2009, Mike Murach & Associates, Inc.Slide 40
Image files
Murach’s JavaScript, C4 © 2009, Mike Murach & Associates, Inc.Slide 42
Image formats supported by most browsers GIF (Graphic Interchange Format)
JPEG (Joint Photographic Experts Group)
PNG (Portable Network Graphics)
Exercise #5
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 44
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc. Slide 45
Murach’s JavaScript, C4 © 2009, Mike Murach & Associates, Inc.Slide 46
The tags for working with tables
Tag Description
<table> Marks the start and end of a table.
<tr> Marks the start and end of each row.
<th> Marks the start and end of each heading cell within a row.
<td> Marks the start and end of each data cell within a row.
Murach’s JavaScript, C4 © 2009, Mike Murach & Associates, Inc.Slide 47
Common attributes of the <table> tags
Attribute Description
border The thickness of the cell borders in pixels.
cellspacing The space between table cells in pixels.
cellpadding The padding between the cell borders and the contents of the cells.
width The width of the table in pixels or a percentage.
summary A text description of the contents of the table.
Common attributes of the <table> and <tr> tags
Attribute Description
align Controls the horizontal alignment of the content in the row.
valign Controls the vertical alignment of the content in the row.
A little more on Tables
Tables are built horizontally, one row at a time– Rows get divided into columns
The content of a table is not shown until the entire table is loaded
– If you have extremely long pages, you should divide it into two or more tables - allows the user to start reading the upper content while the rest of the page is loading.
Murach’s JavaScript, C4 © 2009, Mike Murach & Associates, Inc.Slide 49
The tags for a simple table <table border="1" cellspacing="1" cellpadding="3" summary="First Quarter Sales By Region"> <tr align="center"> <th>Region</th> <th>Jan</th> <th>Feb</th> </tr> <tr align="right"> <th>West</th> <td>$15,684.34</td> <td>$18,467.86</td> </tr> <tr align="right"> <th>Central</th> <td>$22,497.14</td> <td>$13,371.34</td> </tr> </table>
Murach’s JavaScript, C4 © 2009, Mike Murach & Associates, Inc.Slide 50
The table in a web browser
Murach’s JavaScript, C4 © 2009, Mike Murach & Associates, Inc.Slide 51
Common attributes of the <th> and <td> tags
Attribute Description
colspan Causes a cell to span multiple columns.
rowspan Causes a cell to span multiple rows.
align Controls the horizontal alignment of the content of the cell.
valign Controls the vertical alignment of the content of the cell.
Murach’s JavaScript, C4 © 2009, Mike Murach & Associates, Inc.Slide 52
Murach’s JavaScript, C4 © 2009, Mike Murach & Associates, Inc.Slide 53
Murach’s JavaScript, C4 © 2009, Mike Murach & Associates, Inc.Slide 54
The table in a web browser
Exercise #6
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 56
Murach’s JavaScript, C4 © 2009, Mike Murach & Associates, Inc.Slide 57
HTML5 &The Document Object Model
Web Technology Stack
HTML
CSS
JavaScript
Structure – What does this logically mean?
Presentation – What does it look like?
Behavior – What does it do?
Richness of the
Experience
PHP
MySQL
Behavior – What does it do?
Data – What does it know?
Quiz: Logical or Presentation
source: P. Griffiths, "HTML Dog: The Best-Practice Guide to XHTML&CSS, " New Raider, 2007
Quiz: Logical or Presentation
source: P. Griffiths, "HTML Dog: The Best-Practice Guide to XHTML&CSS, " New Raider, 2007
The stillbirth of Cascading Style Sheets
• Created and did not published) style sheet language when inventing HyperText Markup Language in 1990– Fundamental belief: User will want
to control the styling
Reasons why CSS is the bastard child
• Browsers implemented CSS incorrectly and patchy CSS support creates inconsistencies
• Authors' lack of familiarity with CSS syntax and required techniques
• Poor support from authoring tools
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 67
Chapter 5
A crash course in CSS
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc. Slide 68
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 69
A web page before CSS has been applied
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 70
The same page after CSS has been applied
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc. Slide 71
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 72
The parts of a CSS rule set
h1 { color: blue; font-size: 14pt;}
selector
valueproperty
declaration
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 73
Another CSS rule set body { margin-top: 0; background-color: dodgerBlue; font-family: Georgia, "Times New Roman", Times, serif; font-size: 10pt; }
A CSS rule set with a complex selector h1, #footer, .gray { color: gray; }
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 74
A CSS comment /* This is a CSS comment */
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 75
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc. Slide 76
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 77
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 78
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 79
CSS Media (Device) TypeType Description
all All media type devices
aural Speech and sound synthesizers
braille Braille tactile feedback devices
embossed Paged braille printers
handheld Small or handheld devices
print Printers
projection Projected presentations (slides)
screen Computer screens
tty Fixed-pitch character grid devices (teletypes and terminals)
tv Television-type devices
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc. Slide 81
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 82
Common units of measurement
Symbol Name Type
px pixels absolute
pt points absolute
em ems relative
% percentages relative
Four ways to specify font size font-size: 12pt; font-size: 16px; font-size: 1em; font-size: 100%;
Two ways to specify width width: 760px; width: 80%;
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc. Slide 83
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 84
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc. Slide 85
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 86
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 87
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 88
The elements displayed in a browser
A little more on tag-based selectors
Adapted from Maxdesign.com.au
A little more on class-based selectors
Adapted from Maxdesign.com.au
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc. Slide 91
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 92
A little more on universal selector
Adapted from Maxdesign.com.au
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 94
A little more on descendent selectors
Adapted from Maxdesign.com.au
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 96
A little more on Child Selectors
Adapted from Maxdesign.com.au
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 98
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc. Slide 99
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 100
Pseudo-class selectors
Name Description
:link A link that hasn’t been visited.
:visited A link that has been visited.
:hover An element when the mouse is hovering over it.
:active An element that’s currently active.
:first-child An element that’s the first child element.
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 101
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 102
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 103
The pseudo-class selectors in a web browser
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc. Slide 104
Cascade is postponed to later
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc. Slide 106
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 107
Three of the five generic font families
Name Description
serif Fonts with tapered, flared, or slab stroke ends.
sans-serif Fonts with plain stroke ends.
monospace Fonts that use the same width for each character.
Examples of three common font families Times New Roman is a serif font. It is the default for most web
browsers.
Arial is a sans-serif font. It is widely used.
Courier New is a monospace font.
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 108
How to specify a font family font-family: "Times New Roman", Times, serif; font-family: Arial, Helvetica, sans-serif; font-family: "Courier New", Courier, monospace;
How to specify font styles, weights, and variants font-style: italic; font-weight: bold; font-variant: small-caps;
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 109
How to specify font size and line height font-size: 12pt; font-size: 150%; font-size: 1.5em; /* same as 150% for font-size */ line-height: 14pt; line-height: 120%; line-height: 1.2em; /* same as 120% for line-height */
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 110
The syntax for the shorthand font property font: [style] [weight] [variant] size[/line-height] family;
How to use the shorthand font property font: italic bold 14px/16px Arial, sans-serif; font: small-caps 150% "Times New Roman", Times, serif; font: 90%/120% "Comic Sans MS", Impact, sans-serif;
Exercise #8
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 112
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 113
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc. Slide 114
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 115
How to transform text text-transform: uppercase;
Valid values uppercase lowercase capitalize none
How to add decorations to text text-decoration: underline;
Valid values underline overline line-through blink none
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 116
How to indent the first line of text text-indent: 2em; text-indent: 25px; text-indent: 10%;
How to horizontally align text text-align: left;
Valid values left center right justify
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 117
The XHTML for one heading and three paragraphs <h3>Mike's Bait & Tackle Shop</h3> <p>We have all the gear you'll need to make your next fishing trip a great success!</p> <p class="contact"><a href="contact.html">Contact us</a> to place your order today!</p> <p class="copyright">© 2008</p>
The CSS for the text h3 { text-align: center; text-transform: uppercase; text-decoration: underline overline; } p { text-indent: 2em; } .contact { text-indent: 0em; } .copyright { text-align: right; }
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 118
The text in a browser
Exercise #9
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 120
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc. Slide 121
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 122
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 123
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 124
XHTML for a list example <ol> <li>Windows</li> <li>Mac OS</li> <li>Linux</li> </ol> <ul> <li>Internet Explorer</li> <li>Firefox</li> <li>Safari</li> </ul>
CSS for a list example ol { list-style-type: upper-alpha; } ul { list-style-type: circle; }
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 125
The list example displayed in a web browser
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 126
How to use an image as a bullet list-style-image: none; /* default value */ list-style-image: url("star.gif");
An image as a bullet in the web browser
Exercise #10
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 128
Homework
1. Refactor CSS code done in class and create main.css and create external link to both home and about web pages
2. Apply CSS styling rules to table in about web page and place new styling rules in main.css
Murach’s JavaScript, C5 © 2009, Mike Murach & Associates, Inc.Slide 129