SlideShare a Scribd company logo
1 of 22
Introduction to HTML and
CSS
Lecture 2
Goals	

CSS

CSS Classes

Floating elements

Cascading elements
CSS


Definition: Cascading Style Sheets

CSS defines how HTML elements are displayed.
Three ways to define
    CSS Styles
Inline-styles


You can add a ‘style’ attribute to any HTML
element and define your styles there

  <div style=”width:50px;height:50px;”></div>
  <div width=”50” height=”50”></div>
Internal Style Sheet


You can also place a <style> tag in the <head>
portion of your HTML document and define your
CSS there
  <head>
   <style type=”text/css”>
      …
   </style>
  </head>
External Style Sheets
The most common place for CSS is an external
style sheet

   Which is a file with a .css extension

To access this file you will need to use the HTML
<link> element

   You place a <link> between your HTML <head>
   tags
<head>
  <link href="stylesheet.css" rel="stylesheet" type="text/css">
</head>
CSS Syntax
A typical CSS statement looks like this:
         SELECTOR {
             DECLARATION;
             PROPERTY: VALUE;
         }
For Example:
               h1 { color: #FFFFFF; }

               Selector-> h1
               Declaration-> color: #FFFFFF;
               Property-> color
               Value-> #FFFFFF
CSS Syntax Cont...




        THANKS W3SCHOOLS.COM !!
CSS Syntax Cont.	

CSS declarations always end with a semicolon,
and curly brackets surround declaration groups.

Do not leave spaces between property values and
units                      THERE’S A SPACE HERE

               incorrect 	 width: 20 px;
               correct	 	 width: 20px;
Open Core-Concepts
sheet in Dropbox

Dropbox/Lecture2/CSS core concepts.doc

Go to page 5: Common CSS Attributes
CSS Classes

A special non-unique case for elements. Classes
should be used when multiple elements require
the same styling
<html>
 <head>
   <style type=”text/css”>
     .box {
         width: 50px;
         height: 50px;
      }	
    </style>
 </head>
 <body>
   <div class=”box”></div>
   <div class=”box”></div>
   <div class=”box”></div>
 </body>
</html>
CSS Classes Cont...	

CSS classes are declared with a period ‘.’ followed
by a unique name

  Such as ‘.box’ in the previous example

In CSS if you follow a class declaration with a
selector you can define specific declarations for
that element
CSS Classes Cont...
Where ‘.box’ is the class, ‘p’ is the selector and
‘color: green;’ is the declaration



                   .box p {
                     color: green;
                   }
Let’s change it up a bit

Add background color to the boxes

Add a border to the boxes

Add margin to the boxes

Float all boxes left
Exercise Floating
Objects
Cascading Style Sheets


When an HTML element has multiple styles
defined on it the one with the highest priority will
be chosen and override the rest.
Cascading Style Sheets
Cont...
An inline style has the highest priority and will
override any other CSS defined

Internal style sheet

External style sheets

  These are typically declared before the internal
  style sheets

Browser default options are at the bottom of the
list, and will have the lowest priority.
Cascading Example
Helpful links

http://www.w3schools.com/css/default.asp

http://www.w3schools.com/css/css_syntax.asp

http://www.w3schools.com/css/css_id_class.asp

http://www.w3schools.com/css/css_float.asp
Homework


Implement the design for the three floating blocks

More Related Content

What's hot

Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
Marc Steel
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
eShikshak
 

What's hot (20)

Css ppt
Css pptCss ppt
Css ppt
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
 
CSS Basic Introduction, Rules, And Tips
CSS Basic Introduction, Rules, And TipsCSS Basic Introduction, Rules, And Tips
CSS Basic Introduction, Rules, And Tips
 
Cascading Style Sheet (CSS)
Cascading Style Sheet (CSS)Cascading Style Sheet (CSS)
Cascading Style Sheet (CSS)
 
Cascading Style Sheet
Cascading Style SheetCascading Style Sheet
Cascading Style Sheet
 
CSS
CSS CSS
CSS
 
Cascading Style Sheet | CSS
Cascading Style Sheet | CSSCascading Style Sheet | CSS
Cascading Style Sheet | CSS
 
CSS (Cascading Style Sheet)
CSS (Cascading Style Sheet)CSS (Cascading Style Sheet)
CSS (Cascading Style Sheet)
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
 
Css
CssCss
Css
 
Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)
 
Introduction to css & its attributes with syntax
Introduction to css & its attributes with syntaxIntroduction to css & its attributes with syntax
Introduction to css & its attributes with syntax
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 
Cascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) helpCascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) help
 
Introducing Cascading Style Sheets
Introducing Cascading Style SheetsIntroducing Cascading Style Sheets
Introducing Cascading Style Sheets
 
CSS
CSSCSS
CSS
 
Beginners css tutorial for web designers
Beginners css tutorial for web designersBeginners css tutorial for web designers
Beginners css tutorial for web designers
 
CSS
CSSCSS
CSS
 
Html
HtmlHtml
Html
 
CSS 101
CSS 101CSS 101
CSS 101
 

Viewers also liked (7)

Interactive Graphics using Javascript, HTML5 and CSS3
Interactive Graphics using Javascript, HTML5 and CSS3Interactive Graphics using Javascript, HTML5 and CSS3
Interactive Graphics using Javascript, HTML5 and CSS3
 
Lecture3
Lecture3Lecture3
Lecture3
 
Iagc2
Iagc2Iagc2
Iagc2
 
Lecture 2 adv
Lecture 2 advLecture 2 adv
Lecture 2 adv
 
Lecture 1 adv
Lecture 1 advLecture 1 adv
Lecture 1 adv
 
HTML/CSS Lecture 1
HTML/CSS Lecture 1HTML/CSS Lecture 1
HTML/CSS Lecture 1
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI Explainer
 

Similar to Lecture2 (20)

Css
CssCss
Css
 
Web topic 15 1 basic css layout
Web topic 15 1  basic css layoutWeb topic 15 1  basic css layout
Web topic 15 1 basic css layout
 
WT CSS
WT  CSSWT  CSS
WT CSS
 
Html Styles-CSS
Html Styles-CSSHtml Styles-CSS
Html Styles-CSS
 
Web app development_html_css_03
Web app development_html_css_03Web app development_html_css_03
Web app development_html_css_03
 
Css notes
Css notesCss notes
Css notes
 
Web Programming& Scripting Lab
Web Programming& Scripting LabWeb Programming& Scripting Lab
Web Programming& Scripting Lab
 
Css
CssCss
Css
 
Css
CssCss
Css
 
CSS Foundations, pt 2
CSS Foundations, pt 2CSS Foundations, pt 2
CSS Foundations, pt 2
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
 
CSS Overview
CSS OverviewCSS Overview
CSS Overview
 
Css ms megha
Css ms meghaCss ms megha
Css ms megha
 
Css introduction
Css introductionCss introduction
Css introduction
 
CSS.pdf
CSS.pdfCSS.pdf
CSS.pdf
 
DW_lesson2.ppt
DW_lesson2.pptDW_lesson2.ppt
DW_lesson2.ppt
 
DW_lesson2.ppt
DW_lesson2.pptDW_lesson2.ppt
DW_lesson2.ppt
 
DW_lesson2.ppt
DW_lesson2.pptDW_lesson2.ppt
DW_lesson2.ppt
 
DW_lesson2.ppt
DW_lesson2.pptDW_lesson2.ppt
DW_lesson2.ppt
 
DW_lesson2.ppt
DW_lesson2.pptDW_lesson2.ppt
DW_lesson2.ppt
 

Recently uploaded

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
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
QucHHunhnh
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Recently uploaded (20)

Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.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
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 

Lecture2

Editor's Notes