SlideShare une entreprise Scribd logo
1  sur  39
Today
• CSS
• 4/10 Monday (#322)
– Tutorial 7: Case 1 (4th edition)
– Read the book and handouts carefully
– Due by 4/12 (Wed.)

• A project planning document by 4/12
The Breakdown
• All web pages can be broken down into
bucketized content areas
• These areas can updated by changing
the code on every page,
- or • By using cascading style sheets!
Advantages of Style Sheets
•
•
•
•
•
•

Saves time
Easy to change
Keep consistency
Give you more control over layout
Use styles with JavaScript => DHTML
Make it easy to create a common format for all
the Web pages
Applying a single style sheet to
multiple documents
Basic Structure of a Style
• Each definition contains:
–
–
–
–

A property
A colon
A value
A semicolon to separate two or more
values
– Can include one or more values

• h1 {font-size:12pt; color:red}
Style Precedence
1. External style sheet
2. Embedded styles
3. Inline styles
Three Style Types
• Inline styles
– Add styles to each tag within the HTML
file
– Use it when you need to format just a
single section in a web page

• Example
– <h1 style=“color:red; font-family: sanssarif”>IU</h1>
Three Style Types
• Embedded or internal styles
– A style is applied to the entire HTML file
– Use it when you need to modify all
instances of particular element (e.g., h1)
in a web page

• Example
– <style>
•

h1 {color:red; font-family:sans-serif}

– </style>
Creating an Embedded Style
<head>
<title>Embedded Example</title>
<style> (default is “text/css”)
Style declarations
</style>
</head>
• A style declaration:
– Selector {attribute1:value1; attribute2:value2;
…}
– Selector = an element in a document (e.g., a
header or paragraph)
An Example of an embedded style
(p. 353 Fig 7-2)
<head>
<title>Getting Started</title>
<style type=“text/css”>
h1 {font-family: sans-serif; color: organge}
</style>
</head>
Three Style Types
• External style sheets
– An external style sheet is a text file containing
the style definition (declaration)
– Use it when you need to control the style for an
entire web site

• Example
– h1, h2, h3, h4, h5, h6 {color:red; fontfamily:sans-serif}
– Save this in a new document using a .css
extension
Creating an External Style
Sheet
• Open a new blank document in
Notepad
• Type style declarations
– h1 {color:red; font-family:sans-serif;}

• Do not include <style> tags
• Save the document as filename.css
Linking to Style Sheets 1
• Open an HTML file
• Between <head> and </head> add
– <link href=URL rel=“relation_type”
type=“link_type”>
•
•
•

URL is the file.css
Relation_type=“stylesheet”
Link_type=“text/css”

• Save this file and the .css file in the
same web server directory
An example of an external style
sheet with an original html file
<head>
<title>Getting
Started</title>
<link href=“scraps.css”
rel=“stylesheet”
type=“text/css” />
</head>

h1 {font-family: sansserif; color: orange}
b {color: blue}

Text file of css named “stylesheet”
html file
Style Sheet Strategies
• Wherever possible, place your styles
in external style sheets
• Take advantage of the power of CSS
to have control over an entire Web
site
Style Sheet Strategies
• At the top level of your web site:
define a default global.css style sheet
• Refine styles at sublevels with a
section.css style sheet
• Try to avoid using styles in tags
Attribute Selectors
• Create an attribute selector to select
an element based on the element’s
attributes.
– See figure 7-13 in your text for a list of
attribute selectors
Using IDs and Classes
• Use an id to distinguish something,
like a paragraph, from the others in a
document.
– For example, to identify a paragraph as
“head”, use the code:
<p id=“head”>… </p>
Working With Ids
• To create an ID for a specific tag, use the
property:
– <tag ID=id_name>

• To apply a style to a specific ID, use:
– #id_name {style attributes and values}
Classes
• HTML and XHTML require each id
be unique– therefore an id value can
only be used once in a document.
• You can mark a group of elements
with a common identifier using the
class attribute.
<element class=“class”> … </element>
Applying a style to a class
Working With Classes
• To create a class, enter the following in the
HTML tag:
– <tag CLASS=class_name>
– <h1 CLASS=FirstHeader>IU</h1>
– class_name is a name to identify this class of
tags

• To apply a style to a class of tags, use:
– tag.class_name {style attributes} or
– .class_name {style attributes}
Working With Classes and Ids
• The difference between the Class
property and the ID property is that the
value of the ID property must be unique:
– you can’t have more than one tag with the
same ID value
– You can apply the same Class value to
multiple document tags
Working With DIV
• <DIV> tag is used for blocks of text, e.g.,
paragraphs, block quotes, headers, or lists
• To create a container for block-level elements,
use:
– <DIV CLASS=class_name>
•

Block-level elements

– </DIV>
– Class_name is the name of the class
– You can substitute the ID proper for the Class
property (with ID, the syntax for CSS style,

#id_name {style attributes and values}
Working With <DIV> (p. 372)
DIV.Slogan {font-weigh:bold}
style
Maxwell…:
“We
teach…
Resulting
<DIV CLASS=Slogan>Maxwell Scientific’s new
Slogan is:<BR>”We teach science”</DIV>

HTML code

text
Working With <span>
• With the <span> tag, you can use
inline elements, e.g., <B>, <I>
• To create a container for inline
elements, use:
– <span CLASS=class_name>
•

inline elements

– </span>
CSS for Page Layout
• CSS manipulates the size and location of blocklevel elements
• Block-level elements in HTML:
–
–
–
–
–
–
–
–

Heading tags, e.g., <H1>, <H2>
<p>
<blockquote> and <address> tags
List tags, e.g., <ul>, <ol>, <dl>
<div>
<body>
<hr>
<img>
CSS for Page Layout
• Parts of the block-level elements:
– Margin
– Border
– Padding
CSS for Page Layout (Carey,
7.49)

I appreciate the prompt delivery of
the pack of star disks.

padding

margin

border
Controlling the Margins
• To define the margins of an element, use:
– margin:value
– where value = a length value (“em” is often
used), a percentage (a margin proportional
to the element’s width, or auto
Controlling the Margins
• To set margins on a side, use:
–
–
–
–

margin-top
margin-right
margin-bottom
margin-left

• E.g., LI {margin-left:2em; margin-right:2em;
margin-top:1em; margin-bottom:1em}
Setting the Padding Size
• To define padding, use:
– padding: value
– where value = a length value or a percentage
(a padding proportional to the element’s
width)
Setting the Padding Size
• To set margins on a side, use:
–
–
–
–

padding-top
padding-right
padding-bottom
padding-left
Formatting the Border
• Border can be set in three ways:
– border-width
– border-style
– border-color
Formatting the Border
• To set the border, use:
– border:width_value style color

• To set borders on a side, use:
–
–
–
–

border-top
border-bottom
border-left
border-right

• Carey 7.52-7.53
Formatting Width & Height of
Block-Level Boxes
• To set the width of a block-level element, use:
– width:value
– height:value
– where value can be a length value, a percentage, or
auto

• E.g., textarea {width:225px; height:100px}
Using the Float Attribute
(p. 371-372)
• To float (wrap) a block-level element, use:
– float:margin
– Where margin = right, left, none

• To prevent an element from wrapping, use:
– Clear:margin
– Where margin=right, left, both, none
Using the Float Attribute
float:right
width:50px

float:right
width:50px
clear:right
Formatting Hypertext Links
• To remove the style of underlining hypertext,
use:
– A {text-decoration:none}

• 4 types of hyperlinks can be modified:
– A:visited {styles for previously visited links}
– A:link {styles for links that have never visited}
– A:active {styles for links that are currently being
clicked}
– A:hover {styles when the mouse cursor is hovering
over the link}

Contenu connexe

Tendances

JDBC : Java Database Connectivity
JDBC : Java Database Connectivity JDBC : Java Database Connectivity
JDBC : Java Database Connectivity DevAdnani
 
Java database connectivity
Java database connectivityJava database connectivity
Java database connectivityVaishali Modi
 
Basic Java Database Connectivity(JDBC)
Basic Java Database Connectivity(JDBC)Basic Java Database Connectivity(JDBC)
Basic Java Database Connectivity(JDBC)suraj pandey
 
PROGRAMMING IN JAVA- unit 4-part I
PROGRAMMING IN JAVA- unit 4-part IPROGRAMMING IN JAVA- unit 4-part I
PROGRAMMING IN JAVA- unit 4-part ISivaSankari36
 
Java- JDBC- Mazenet Solution
Java- JDBC- Mazenet SolutionJava- JDBC- Mazenet Solution
Java- JDBC- Mazenet SolutionMazenetsolution
 
Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)Pooja Talreja
 
Jdbc architecture and driver types ppt
Jdbc architecture and driver types pptJdbc architecture and driver types ppt
Jdbc architecture and driver types pptkamal kotecha
 
JAXB: Create, Validate XML Message and Edit XML Schema
JAXB: Create, Validate XML Message and Edit XML SchemaJAXB: Create, Validate XML Message and Edit XML Schema
JAXB: Create, Validate XML Message and Edit XML SchemaSitdhibong Laokok
 
JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...
JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...
JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...Pallepati Vasavi
 
Dao pattern
Dao patternDao pattern
Dao patternciriako
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language Hitesh-Java
 

Tendances (20)

Jdbc
JdbcJdbc
Jdbc
 
JDBC : Java Database Connectivity
JDBC : Java Database Connectivity JDBC : Java Database Connectivity
JDBC : Java Database Connectivity
 
Java database connectivity
Java database connectivityJava database connectivity
Java database connectivity
 
Basic Java Database Connectivity(JDBC)
Basic Java Database Connectivity(JDBC)Basic Java Database Connectivity(JDBC)
Basic Java Database Connectivity(JDBC)
 
PROGRAMMING IN JAVA- unit 4-part I
PROGRAMMING IN JAVA- unit 4-part IPROGRAMMING IN JAVA- unit 4-part I
PROGRAMMING IN JAVA- unit 4-part I
 
Hibernate 3
Hibernate 3Hibernate 3
Hibernate 3
 
Core jdbc basics
Core jdbc basicsCore jdbc basics
Core jdbc basics
 
JDBC
JDBCJDBC
JDBC
 
Java- JDBC- Mazenet Solution
Java- JDBC- Mazenet SolutionJava- JDBC- Mazenet Solution
Java- JDBC- Mazenet Solution
 
Chap3 3 12
Chap3 3 12Chap3 3 12
Chap3 3 12
 
Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)
 
Jdbc architecture and driver types ppt
Jdbc architecture and driver types pptJdbc architecture and driver types ppt
Jdbc architecture and driver types ppt
 
JAXB: Create, Validate XML Message and Edit XML Schema
JAXB: Create, Validate XML Message and Edit XML SchemaJAXB: Create, Validate XML Message and Edit XML Schema
JAXB: Create, Validate XML Message and Edit XML Schema
 
JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...
JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...
JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...
 
Dao pattern
Dao patternDao pattern
Dao pattern
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language
 
JSP - Part 1
JSP - Part 1JSP - Part 1
JSP - Part 1
 
Aem best practices
Aem best practicesAem best practices
Aem best practices
 
Database Access With JDBC
Database Access With JDBCDatabase Access With JDBC
Database Access With JDBC
 
Overview Of JDBC
Overview Of JDBCOverview Of JDBC
Overview Of JDBC
 

En vedette

A beginner's guide to twitter bootstrap
A beginner's guide to twitter bootstrapA beginner's guide to twitter bootstrap
A beginner's guide to twitter bootstrapSunanda Bansal
 
Bootstrap 3 Cheat Sheet PDF Reference
Bootstrap 3 Cheat Sheet PDF ReferenceBootstrap 3 Cheat Sheet PDF Reference
Bootstrap 3 Cheat Sheet PDF ReferenceBootstrap Creative
 
AngularJS Forms Validation
AngularJS Forms ValidationAngularJS Forms Validation
AngularJS Forms ValidationSunny Sharma
 
Angular workshop - Full Development Guide
Angular workshop - Full Development GuideAngular workshop - Full Development Guide
Angular workshop - Full Development GuideNitin Giri
 
Design for Developers: Introduction to Bootstrap 3
Design for Developers: Introduction to Bootstrap 3Design for Developers: Introduction to Bootstrap 3
Design for Developers: Introduction to Bootstrap 3John Bertucci
 

En vedette (9)

CSS Cheat Sheet Reference PDF
CSS Cheat Sheet Reference PDFCSS Cheat Sheet Reference PDF
CSS Cheat Sheet Reference PDF
 
Angularjs
AngularjsAngularjs
Angularjs
 
A beginner's guide to twitter bootstrap
A beginner's guide to twitter bootstrapA beginner's guide to twitter bootstrap
A beginner's guide to twitter bootstrap
 
Bootstrap 3 Cheat Sheet PDF Reference
Bootstrap 3 Cheat Sheet PDF ReferenceBootstrap 3 Cheat Sheet PDF Reference
Bootstrap 3 Cheat Sheet PDF Reference
 
Twitter bootstrap 101
Twitter bootstrap 101Twitter bootstrap 101
Twitter bootstrap 101
 
Bootstarp 3
Bootstarp 3Bootstarp 3
Bootstarp 3
 
AngularJS Forms Validation
AngularJS Forms ValidationAngularJS Forms Validation
AngularJS Forms Validation
 
Angular workshop - Full Development Guide
Angular workshop - Full Development GuideAngular workshop - Full Development Guide
Angular workshop - Full Development Guide
 
Design for Developers: Introduction to Bootstrap 3
Design for Developers: Introduction to Bootstrap 3Design for Developers: Introduction to Bootstrap 3
Design for Developers: Introduction to Bootstrap 3
 

Similaire à Css

Similaire à Css (20)

Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheets
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheets
 
BITM3730Week4.pptx
BITM3730Week4.pptxBITM3730Week4.pptx
BITM3730Week4.pptx
 
Html Css
Html CssHtml Css
Html Css
 
Html css
Html cssHtml css
Html css
 
Html and css easy steps
Html and css easy stepsHtml and css easy steps
Html and css easy steps
 
Html css
Html cssHtml css
Html css
 
03html Css
03html Css03html Css
03html Css
 
Ifi7174 lesson2
Ifi7174 lesson2Ifi7174 lesson2
Ifi7174 lesson2
 
css.pdf
css.pdfcss.pdf
css.pdf
 
Css
CssCss
Css
 
Cascading Style Sheets for web browser.pptx
Cascading Style Sheets for web browser.pptxCascading Style Sheets for web browser.pptx
Cascading Style Sheets for web browser.pptx
 
basic programming language AND HTML CSS JAVApdf
basic programming language AND HTML CSS JAVApdfbasic programming language AND HTML CSS JAVApdf
basic programming language AND HTML CSS JAVApdf
 
ch04-css-basics_final.ppt
ch04-css-basics_final.pptch04-css-basics_final.ppt
ch04-css-basics_final.ppt
 
CSS
CSSCSS
CSS
 
Css
CssCss
Css
 
uptu web technology unit 2 Css
uptu web technology unit 2 Cssuptu web technology unit 2 Css
uptu web technology unit 2 Css
 
Cascading Style Sheets By Mukesh
Cascading Style Sheets By MukeshCascading Style Sheets By Mukesh
Cascading Style Sheets By Mukesh
 
4. Web Technology CSS Basics-1
4. Web Technology CSS Basics-14. Web Technology CSS Basics-1
4. Web Technology CSS Basics-1
 
xhtml_css.ppt
xhtml_css.pptxhtml_css.ppt
xhtml_css.ppt
 

Plus de myrajendra

Plus de myrajendra (20)

Fundamentals
FundamentalsFundamentals
Fundamentals
 
Data type
Data typeData type
Data type
 
Jdbc workflow
Jdbc workflowJdbc workflow
Jdbc workflow
 
Sessionex1
Sessionex1Sessionex1
Sessionex1
 
Internal
InternalInternal
Internal
 
3. elements
3. elements3. elements
3. elements
 
2. attributes
2. attributes2. attributes
2. attributes
 
1 introduction to html
1 introduction to html1 introduction to html
1 introduction to html
 
Headings
HeadingsHeadings
Headings
 
Forms
FormsForms
Forms
 
Views
ViewsViews
Views
 
Views
ViewsViews
Views
 
Views
ViewsViews
Views
 
Starting jdbc
Starting jdbcStarting jdbc
Starting jdbc
 
Properties
PropertiesProperties
Properties
 
Interface callable statement
Interface callable statementInterface callable statement
Interface callable statement
 
Interface result set
Interface result setInterface result set
Interface result set
 
Interface database metadata
Interface database metadataInterface database metadata
Interface database metadata
 
Interface connection
Interface connectionInterface connection
Interface connection
 
Indexing
IndexingIndexing
Indexing
 

Dernier

Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 

Dernier (20)

Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 

Css

  • 1. Today • CSS • 4/10 Monday (#322) – Tutorial 7: Case 1 (4th edition) – Read the book and handouts carefully – Due by 4/12 (Wed.) • A project planning document by 4/12
  • 2. The Breakdown • All web pages can be broken down into bucketized content areas • These areas can updated by changing the code on every page, - or • By using cascading style sheets!
  • 3. Advantages of Style Sheets • • • • • • Saves time Easy to change Keep consistency Give you more control over layout Use styles with JavaScript => DHTML Make it easy to create a common format for all the Web pages
  • 4. Applying a single style sheet to multiple documents
  • 5. Basic Structure of a Style • Each definition contains: – – – – A property A colon A value A semicolon to separate two or more values – Can include one or more values • h1 {font-size:12pt; color:red}
  • 6. Style Precedence 1. External style sheet 2. Embedded styles 3. Inline styles
  • 7. Three Style Types • Inline styles – Add styles to each tag within the HTML file – Use it when you need to format just a single section in a web page • Example – <h1 style=“color:red; font-family: sanssarif”>IU</h1>
  • 8. Three Style Types • Embedded or internal styles – A style is applied to the entire HTML file – Use it when you need to modify all instances of particular element (e.g., h1) in a web page • Example – <style> • h1 {color:red; font-family:sans-serif} – </style>
  • 9. Creating an Embedded Style <head> <title>Embedded Example</title> <style> (default is “text/css”) Style declarations </style> </head> • A style declaration: – Selector {attribute1:value1; attribute2:value2; …} – Selector = an element in a document (e.g., a header or paragraph)
  • 10. An Example of an embedded style (p. 353 Fig 7-2) <head> <title>Getting Started</title> <style type=“text/css”> h1 {font-family: sans-serif; color: organge} </style> </head>
  • 11. Three Style Types • External style sheets – An external style sheet is a text file containing the style definition (declaration) – Use it when you need to control the style for an entire web site • Example – h1, h2, h3, h4, h5, h6 {color:red; fontfamily:sans-serif} – Save this in a new document using a .css extension
  • 12. Creating an External Style Sheet • Open a new blank document in Notepad • Type style declarations – h1 {color:red; font-family:sans-serif;} • Do not include <style> tags • Save the document as filename.css
  • 13. Linking to Style Sheets 1 • Open an HTML file • Between <head> and </head> add – <link href=URL rel=“relation_type” type=“link_type”> • • • URL is the file.css Relation_type=“stylesheet” Link_type=“text/css” • Save this file and the .css file in the same web server directory
  • 14. An example of an external style sheet with an original html file <head> <title>Getting Started</title> <link href=“scraps.css” rel=“stylesheet” type=“text/css” /> </head> h1 {font-family: sansserif; color: orange} b {color: blue} Text file of css named “stylesheet” html file
  • 15. Style Sheet Strategies • Wherever possible, place your styles in external style sheets • Take advantage of the power of CSS to have control over an entire Web site
  • 16. Style Sheet Strategies • At the top level of your web site: define a default global.css style sheet • Refine styles at sublevels with a section.css style sheet • Try to avoid using styles in tags
  • 17. Attribute Selectors • Create an attribute selector to select an element based on the element’s attributes. – See figure 7-13 in your text for a list of attribute selectors
  • 18. Using IDs and Classes • Use an id to distinguish something, like a paragraph, from the others in a document. – For example, to identify a paragraph as “head”, use the code: <p id=“head”>… </p>
  • 19. Working With Ids • To create an ID for a specific tag, use the property: – <tag ID=id_name> • To apply a style to a specific ID, use: – #id_name {style attributes and values}
  • 20. Classes • HTML and XHTML require each id be unique– therefore an id value can only be used once in a document. • You can mark a group of elements with a common identifier using the class attribute. <element class=“class”> … </element>
  • 21. Applying a style to a class
  • 22. Working With Classes • To create a class, enter the following in the HTML tag: – <tag CLASS=class_name> – <h1 CLASS=FirstHeader>IU</h1> – class_name is a name to identify this class of tags • To apply a style to a class of tags, use: – tag.class_name {style attributes} or – .class_name {style attributes}
  • 23. Working With Classes and Ids • The difference between the Class property and the ID property is that the value of the ID property must be unique: – you can’t have more than one tag with the same ID value – You can apply the same Class value to multiple document tags
  • 24. Working With DIV • <DIV> tag is used for blocks of text, e.g., paragraphs, block quotes, headers, or lists • To create a container for block-level elements, use: – <DIV CLASS=class_name> • Block-level elements – </DIV> – Class_name is the name of the class – You can substitute the ID proper for the Class property (with ID, the syntax for CSS style, #id_name {style attributes and values}
  • 25. Working With <DIV> (p. 372) DIV.Slogan {font-weigh:bold} style Maxwell…: “We teach… Resulting <DIV CLASS=Slogan>Maxwell Scientific’s new Slogan is:<BR>”We teach science”</DIV> HTML code text
  • 26. Working With <span> • With the <span> tag, you can use inline elements, e.g., <B>, <I> • To create a container for inline elements, use: – <span CLASS=class_name> • inline elements – </span>
  • 27. CSS for Page Layout • CSS manipulates the size and location of blocklevel elements • Block-level elements in HTML: – – – – – – – – Heading tags, e.g., <H1>, <H2> <p> <blockquote> and <address> tags List tags, e.g., <ul>, <ol>, <dl> <div> <body> <hr> <img>
  • 28. CSS for Page Layout • Parts of the block-level elements: – Margin – Border – Padding
  • 29. CSS for Page Layout (Carey, 7.49) I appreciate the prompt delivery of the pack of star disks. padding margin border
  • 30. Controlling the Margins • To define the margins of an element, use: – margin:value – where value = a length value (“em” is often used), a percentage (a margin proportional to the element’s width, or auto
  • 31. Controlling the Margins • To set margins on a side, use: – – – – margin-top margin-right margin-bottom margin-left • E.g., LI {margin-left:2em; margin-right:2em; margin-top:1em; margin-bottom:1em}
  • 32. Setting the Padding Size • To define padding, use: – padding: value – where value = a length value or a percentage (a padding proportional to the element’s width)
  • 33. Setting the Padding Size • To set margins on a side, use: – – – – padding-top padding-right padding-bottom padding-left
  • 34. Formatting the Border • Border can be set in three ways: – border-width – border-style – border-color
  • 35. Formatting the Border • To set the border, use: – border:width_value style color • To set borders on a side, use: – – – – border-top border-bottom border-left border-right • Carey 7.52-7.53
  • 36. Formatting Width & Height of Block-Level Boxes • To set the width of a block-level element, use: – width:value – height:value – where value can be a length value, a percentage, or auto • E.g., textarea {width:225px; height:100px}
  • 37. Using the Float Attribute (p. 371-372) • To float (wrap) a block-level element, use: – float:margin – Where margin = right, left, none • To prevent an element from wrapping, use: – Clear:margin – Where margin=right, left, both, none
  • 38. Using the Float Attribute float:right width:50px float:right width:50px clear:right
  • 39. Formatting Hypertext Links • To remove the style of underlining hypertext, use: – A {text-decoration:none} • 4 types of hyperlinks can be modified: – A:visited {styles for previously visited links} – A:link {styles for links that have never visited} – A:active {styles for links that are currently being clicked} – A:hover {styles when the mouse cursor is hovering over the link}