+ All Categories
Home > Documents > ECA 228 Internet/Intranet Design I

ECA 228 Internet/Intranet Design I

Date post: 05-Jan-2016
Category:
Upload: kasen
View: 34 times
Download: 0 times
Share this document with a friend
Description:
ECA 228 Internet/Intranet Design I. Cascading Style Sheets. CSS rules. Declaration. RULE. h1 { color: red; }. Selector. Property. Value. CSS rules cont …. each rule has 2 parts selector : determines to which element a rule is applied - PowerPoint PPT Presentation
21
ECA 228 Internet/Intranet Design I Cascading Style Sheets
Transcript
Page 1: ECA 228 Internet/Intranet Design I

ECA 228 Internet/Intranet Design I

Cascading Style Sheets

Page 2: ECA 228 Internet/Intranet Design I

ECA 228 Internet/Intranet Design I

CSS rules

RULE

h1 { color: red; }

Declaration

Selector Property Value

Page 3: ECA 228 Internet/Intranet Design I

ECA 228 Internet/Intranet Design I

CSS rules cont …

each rule has 2 parts– selector: determines to which element a rule is applied– declaration: the rules to apply to the selector

property: the name of the CSS property that describes the formatting being applied

value: an allowable option to set or describe the property

a rule may have more than one declaration– semicolon must end declarations– semicolon is optional for the last pair

Page 4: ECA 228 Internet/Intranet Design I

ECA 228 Internet/Intranet Design I

Applying CSS

can be applied three ways: 1. Internal 2. External 3. Inline

Internal– rules are placed inside <style> tags in <head> section

<style type=“text/css”>

h1 { color: red; }

</style>

Page 5: ECA 228 Internet/Intranet Design I

ECA 228 Internet/Intranet Design I

CSS Internal Example

<html><head>

<title>CSS Example</title><style type=“text/css”>

h1 { color: red;

}

</style></head>

<body> . . .

Page 6: ECA 228 Internet/Intranet Design I

ECA 228 Internet/Intranet Design I

Selectors

element type

to apply a rule to more than one element, separate them with a comma

h1 { color: red; }

h1, h2 { color: red; }

<h1>This will be red></h1>

<h2>So will this</h2>

Page 7: ECA 228 Internet/Intranet Design I

ECA 228 Internet/Intranet Design I

Selectors cont …

class– can be used more than once in HTML– case sensitive– prefixed with dot

.redText { color: red; }

<h1 class=“redText”>This will be red</h1>

Page 8: ECA 228 Internet/Intranet Design I

ECA 228 Internet/Intranet Design I

Selectors cont …

class cont …

– can be used alone or contextually with elements

h1.redText { color: red; }

<h1 class=“redText”>This will be red</h1>

<h2 class=“redText”>This will not</h2>

Page 9: ECA 228 Internet/Intranet Design I

ECA 228 Internet/Intranet Design I

Selectors cont …

id– unique identifier – can only be used once in HTML– prefixed with hash or pound sign #

#redText { color: red; }

<h1 id=“redText”>This will be red</h1>

<h2 id=“redText”>This will be red</h2> ILLEGAL

Page 10: ECA 228 Internet/Intranet Design I

ECA 228 Internet/Intranet Design I

Selectors cont …

context– nested elements can be considered as parent/child– nested relationship is indicated without use of

comma

h1 em { color: red; }

<h1>This word is <em>red</em></h1>

Page 11: ECA 228 Internet/Intranet Design I

ECA 228 Internet/Intranet Design I

Selectors cont …

context cont …

– many properties are inherited ie, if a property belongs to the parent, it also applies to the

child

#div1{ color: red; }

<div id=“div1”>

<h1>This is my header</h1>

</div>

Page 12: ECA 228 Internet/Intranet Design I

ECA 228 Internet/Intranet Design I

Selectors cont …

context cont …

– other properties, such as borders, are not inherited

#border1{ border-style: double;

border-width: thin; }

<div id=“border1”>

<h1>This is my header</h1>

<p>This is my paragraph</p>

</div>

Page 13: ECA 228 Internet/Intranet Design I

ECA 228 Internet/Intranet Design I

Selectors cont …

context cont …

– classes or ids can be nested inside one another

#contentArea .green{ color: green; }

<div id=“contentArea”>

<h1>This is <span class=“green”>green</span></h1>

<p>This is <span class=“green”>green</span> </p>

</div>

Page 14: ECA 228 Internet/Intranet Design I

ECA 228 Internet/Intranet Design I

Selectors cont …

pseudo-class– special type of class that allows formatting based on

a state or condition if a link has been visited or not if the mouse passes over the link when the link is clicked

a:link{ color: blue; text-decoration: none; }

a:visited{ color: pink; text-decoration: none; }

a:hover{ color: purple; text-decoration: underline; }

a:active{ color: red; text-decoration: underline; }

Page 15: ECA 228 Internet/Intranet Design I

ECA 228 Internet/Intranet Design I

Selectors cont …

pseudo-class– special type of class that allows formatting based on

a state or condition first letter of every paragraph first line of every paragraph

p:first-line{ font-size: 120%; }

p:first-letter{ font-size: 150%; font-weight: bold; }

Page 16: ECA 228 Internet/Intranet Design I

ECA 228 Internet/Intranet Design I

Applying CSS

can be applied three ways: 1. Internal 2. External 3. Inline

External– external stylesheet is a separate document– to apply the same stylesheet to more than one page

of a website– provides consistent look– to modify look of site, make changes in one place

Page 17: ECA 228 Internet/Intranet Design I

ECA 228 Internet/Intranet Design I

Applying CSS

External cont …

– no HTML in external stylesheet– no <style> tags in external stylesheet– save as text file, with .css extension– to apply external stylesheet to an HTML document,

link the document from inside the <head> section

<link rel=“stylesheet” type=“text/css” href=“myStyle.css” />

Page 18: ECA 228 Internet/Intranet Design I

ECA 228 Internet/Intranet Design I

Applying CSS

External cont …

– an HTML document can link to more than one external stylesheet at a time, as well as an internal sheet

– if a conflict occurs, precedence is given to the rule defined last

– URLs in an external stylesheet are relative to the location of the stylesheet, not the document linking to it

Page 19: ECA 228 Internet/Intranet Design I

ECA 228 Internet/Intranet Design I

Applying CSS

Inline– used to apply style locally– within an HTML tag use style as an attribute, the rule

as the value– separate definitions with a semicolon

<h1>This word is <span style=“color:red;”>red<span>.</h1>

Page 20: ECA 228 Internet/Intranet Design I

ECA 228 Internet/Intranet Design I

Comments

CSS comments

/* This is a comment */

– using comments is a good way to debug a stylesheet which is not working

– do not confuse /* */ with <! – – – – >

Page 21: ECA 228 Internet/Intranet Design I

ECA 228 Internet/Intranet Design I

Box Model

OUR CONTENTmargin

border

padding


Recommended