SlideShare a Scribd company logo
Lecture 2: CSS II SFDV2001 Web Development
The Box Model In CSS  every  element in your HTML file is contained within a rectangular box. There are four main components to this box: Content Margin Padding Border Additionally there a couple of background components:  background colour background image
Image source:  http://www.hicksdesign.co.uk/boxmodel/
The Box Model Margins are always transparent. Padding is the space between the content and  the border. Background colour and/or image extend throughout the box model to the border. If a style of border used has gaps in it (e.g. dashed), the background shows through those gaps. The background of the parent element shows through the margin area of the box.
Width The width set for an element is the width of the  content . Padding, border and margin are additional to this width. h1{ width: 300px; padding: 5px; border: solid 10px #ff69b4; margin: 10px; } Total width on page for this element = 350 pixels Unless your IE: IE implements the box model incorrectly.
Ā 
IE 5 (Mac) Safari Firefox
Source:  http://en.wikipedia.org/wiki/Image:Box-model-bug.png
Solutions There are hacks to combat many of the flaws in IE’s CSS rendering. Most exploit other IE bugs to provide workarounds. The Box Model hack (by Tantek Ƈelik) width: 350px; voice-family:ā€\ā€}\ā€ā€; voice-family: inherit; width: 300px; IE doesn’t see the second width specification.
Selectors Recap:  selector{ property: value; } There are many different kinds of selectors: Standard element selectors Contextual selectors Class selectors ID selectors Pseudoselectors
Element selectors H1{ color: #456678; } You can group selectors: H1, p, li{ color: #456678; }  You can affect any element using the universal ( * ) selector.
Contextual Selectors Allow you to affect elements based on their context. That is, their relationship to other elements. Descendant selectors Elements that are contained within other elements: ul li{   color: #456678; } ul li a{   color: #456678; }
Contextual Selectors Child Selectors Similar to descendant selectors but it target only a  direct  child of an element: p > em{   color: #456678; }
Contextual Selectors Adjacent sibling selectors H1 + p{ margin-left: 5%; } Affects an element that comes immediately after another. In the above example the first paragraph after a top-level heading will be indented.
Class and ID selectors You can’t always style every element you want to with the standard selectors available and some times you need to make your own. There are two kinds of ā€œcustom-madeā€ selectors:  class  and  ID . Class is used for a style that you may wish to use multiple times in a  single  html file. ID is used for a style you wish to be unique in any  one  html file. You must set the class or ID in your HTML code.
Class and ID selectors IDs take care of unique structural elements: Class is used for elements that are used multiple times : Heading Navigation Footer
Ā 
Class and ID selectors In your style sheet: Class p.question{ color: navy; } Or  .question{   color: navy; }
Class and ID selectors In your style sheet: ID Div#footer{ border-top: solid 1px #555555; font-size: smaller; } Or  #footer{ border-top: solid 1px #555555; font-size: smaller; }
Class and ID selectors Resist the temptation to make everything a class. Make sure your id and class names are descriptive. ā€œnavigationā€ is descriptive of the function of the selector rather than the style. ā€œredā€ is descriptive of a style - styles change. If you can use a contextual selector or the like instead of a class or ID, do so.
Pseudoselectors Some things that you want to style in an html document are not possible to represent with standard element selectors because there is no element in your HTML document to represent them. Different link states - visited, unvisited etc. are good examples. Pseudoselectors enable you to identify these portions of elements. Pseudoselectors are identified in your CSS using a colon. a:link
Pseudoselectors - Anchors Pseudoselectors are most commonly used to influence different link states. a:link a:visited a:hover a:active In transitional code the equivalents are the  link ,  vlink  and  alink  attributes of body. In CSS you get an extra link state (hover) and you can influence any aspect of a links style, not just colour.
Pseudoselectors - Anchors a:link{ text-decoration: none; ... } a:visited{ color:#555555; ... } a:hover{ text-decoration: underline; } a:active{ color:#f6dc3b;   ... }
Pseudoselectors - Anchors Anchor pseudoselectors should appear in your CSS in the order: a  a:link a:visited a:hover a:active If you don't, they may not function as they should. Putting : link  last for example would override the : hover  and : active  states.
Other pseudoselectors There are other pseudoselectors, but they aren't as commonly used as those associated with anchors because of poor browser support. :focus :first-child :first-line :first-letter :before :after :first-line  and  :first-letter  are currently the only ones of this list that have any reasonable browser support.
Block-level and Inline elements In html there are block elements and inline elements. The distinction between the two is important for how they may be nested.  You know from transitional code that  <font>  tags only validate when used inside  <p>  tags. This is because  <font>  is an inline element and  <p>  is a block level element. Block-level elements can contain other block-level elements and inline elements. Inline elements can only contain content and other inline elements.
Ā 
Block-Level and Inline in CSS CSS allows you to explicitly state if an element is block-level or inline. BUT! These have nothing to do with the structure of your HTML and will not change the rules of validation. The notions of block-level and inline in CSS are presentation concepts only. display: block; display: inline;
Ā 
Ā 
Recommended sites: Hicks Design Box Model diagram: http://www.hicksdesign.co.uk/3dboxmodel/ Interactive Box Model diagram: http://www.redmelon.net/tstme/box_model/ W3C's Box Model description: http://www.w3.org/TR/REC-CSS2/box.html Tantek Ƈelik's Box Model hack: http://tantek.com/CSS/Examples/boxmodelhack.html Further reading: Web Design in a Nutshell,  3rd Edition   by Jennifer Niederst Robbins

More Related Content

What's hot (20)

Lecture 1 - Comm Lab: Web @ ITP
Lecture 1 - Comm Lab: Web @ ITPLecture 1 - Comm Lab: Web @ ITP
Lecture 1 - Comm Lab: Web @ ITP
yucefmerhi
Ā 
Lecture 3 Javascript1
Lecture 3  Javascript1Lecture 3  Javascript1
Lecture 3 Javascript1
Sur College of Applied Sciences
Ā 
Lesson plan: HTML Formatting Texts and Paragraphs
Lesson plan: HTML Formatting Texts and ParagraphsLesson plan: HTML Formatting Texts and Paragraphs
Lesson plan: HTML Formatting Texts and Paragraphs
Keith Borgonia Manatad
Ā 
Introduction to basic HTML [Librarian edition]
Introduction to basic HTML [Librarian edition]Introduction to basic HTML [Librarian edition]
Introduction to basic HTML [Librarian edition]
Kosie Eloff
Ā 
Introduction to html fundamental concepts
Introduction to html fundamental conceptsIntroduction to html fundamental concepts
Introduction to html fundamental concepts
Tsebo Shaun Masilo
Ā 
Module 2 Lesson 1
Module 2 Lesson 1Module 2 Lesson 1
Module 2 Lesson 1
claytors
Ā 
Html 5 tutorial - By Bally Chohan
Html 5 tutorial - By Bally ChohanHtml 5 tutorial - By Bally Chohan
Html 5 tutorial - By Bally Chohan
ballychohanuk
Ā 
Lecture 2 introduction to html basics
Lecture 2 introduction to html basicsLecture 2 introduction to html basics
Lecture 2 introduction to html basics
AliMUSSA3
Ā 
Getting Started in Custom Programming for Talent Sourcing
Getting Started in Custom Programming for Talent SourcingGetting Started in Custom Programming for Talent Sourcing
Getting Started in Custom Programming for Talent Sourcing
Glenn Gutmacher
Ā 
HTML validation, microformats, jQuery
HTML validation, microformats, jQueryHTML validation, microformats, jQuery
HTML validation, microformats, jQuery
Jeffrey Barke
Ā 
Lesson plan htmltextformattingtag
Lesson plan htmltextformattingtagLesson plan htmltextformattingtag
Lesson plan htmltextformattingtag
Keith Borgonia Manatad
Ā 
Lesson plan 3
Lesson plan 3Lesson plan 3
Lesson plan 3
Keith Borgonia Manatad
Ā 
Html for beginners part I
Html for beginners part IHtml for beginners part I
Html for beginners part I
Unaib Aslam
Ā 
Hypertext markup language (html)
Hypertext markup language (html)Hypertext markup language (html)
Hypertext markup language (html)
Aksa Sahi
Ā 
Basic html
Basic htmlBasic html
Basic html
Drew Eric Noftle
Ā 
javscript
javscriptjavscript
javscript
rcc1964
Ā 
Deck 893ff61f-1fb8-4e15-a379-775dfdbcee77-12-53
Deck 893ff61f-1fb8-4e15-a379-775dfdbcee77-12-53Deck 893ff61f-1fb8-4e15-a379-775dfdbcee77-12-53
Deck 893ff61f-1fb8-4e15-a379-775dfdbcee77-12-53
Ivy Rueb
Ā 
PL2235 2009 1 HTML
PL2235 2009 1 HTMLPL2235 2009 1 HTML
PL2235 2009 1 HTML
Aliamat UBD
Ā 
Chapter 2 introduction to html5
Chapter 2 introduction to html5Chapter 2 introduction to html5
Chapter 2 introduction to html5
nobel mujuji
Ā 
Rails Girls - Introduction to HTML & CSS
Rails Girls - Introduction to HTML & CSSRails Girls - Introduction to HTML & CSS
Rails Girls - Introduction to HTML & CSS
Timo Herttua
Ā 
Lecture 1 - Comm Lab: Web @ ITP
Lecture 1 - Comm Lab: Web @ ITPLecture 1 - Comm Lab: Web @ ITP
Lecture 1 - Comm Lab: Web @ ITP
yucefmerhi
Ā 
Lesson plan: HTML Formatting Texts and Paragraphs
Lesson plan: HTML Formatting Texts and ParagraphsLesson plan: HTML Formatting Texts and Paragraphs
Lesson plan: HTML Formatting Texts and Paragraphs
Keith Borgonia Manatad
Ā 
Introduction to basic HTML [Librarian edition]
Introduction to basic HTML [Librarian edition]Introduction to basic HTML [Librarian edition]
Introduction to basic HTML [Librarian edition]
Kosie Eloff
Ā 
Introduction to html fundamental concepts
Introduction to html fundamental conceptsIntroduction to html fundamental concepts
Introduction to html fundamental concepts
Tsebo Shaun Masilo
Ā 
Module 2 Lesson 1
Module 2 Lesson 1Module 2 Lesson 1
Module 2 Lesson 1
claytors
Ā 
Html 5 tutorial - By Bally Chohan
Html 5 tutorial - By Bally ChohanHtml 5 tutorial - By Bally Chohan
Html 5 tutorial - By Bally Chohan
ballychohanuk
Ā 
Lecture 2 introduction to html basics
Lecture 2 introduction to html basicsLecture 2 introduction to html basics
Lecture 2 introduction to html basics
AliMUSSA3
Ā 
Getting Started in Custom Programming for Talent Sourcing
Getting Started in Custom Programming for Talent SourcingGetting Started in Custom Programming for Talent Sourcing
Getting Started in Custom Programming for Talent Sourcing
Glenn Gutmacher
Ā 
HTML validation, microformats, jQuery
HTML validation, microformats, jQueryHTML validation, microformats, jQuery
HTML validation, microformats, jQuery
Jeffrey Barke
Ā 
Lesson plan htmltextformattingtag
Lesson plan htmltextformattingtagLesson plan htmltextformattingtag
Lesson plan htmltextformattingtag
Keith Borgonia Manatad
Ā 
Html for beginners part I
Html for beginners part IHtml for beginners part I
Html for beginners part I
Unaib Aslam
Ā 
Hypertext markup language (html)
Hypertext markup language (html)Hypertext markup language (html)
Hypertext markup language (html)
Aksa Sahi
Ā 
javscript
javscriptjavscript
javscript
rcc1964
Ā 
Deck 893ff61f-1fb8-4e15-a379-775dfdbcee77-12-53
Deck 893ff61f-1fb8-4e15-a379-775dfdbcee77-12-53Deck 893ff61f-1fb8-4e15-a379-775dfdbcee77-12-53
Deck 893ff61f-1fb8-4e15-a379-775dfdbcee77-12-53
Ivy Rueb
Ā 
PL2235 2009 1 HTML
PL2235 2009 1 HTMLPL2235 2009 1 HTML
PL2235 2009 1 HTML
Aliamat UBD
Ā 
Chapter 2 introduction to html5
Chapter 2 introduction to html5Chapter 2 introduction to html5
Chapter 2 introduction to html5
nobel mujuji
Ā 
Rails Girls - Introduction to HTML & CSS
Rails Girls - Introduction to HTML & CSSRails Girls - Introduction to HTML & CSS
Rails Girls - Introduction to HTML & CSS
Timo Herttua
Ā 

Viewers also liked (7)

Hidden Profit
Hidden ProfitHidden Profit
Hidden Profit
Linctel Ltd
Ā 
Friendship
FriendshipFriendship
Friendship
Sonja Ridden
Ā 
Life On A Train
Life On A TrainLife On A Train
Life On A Train
MJD Management Group
Ā 
Friendship
FriendshipFriendship
Friendship
Sonja Ridden
Ā 
Race
RaceRace
Race
sabinecharette
Ā 
Presentation at Milagrow SME Conference
Presentation at Milagrow SME ConferencePresentation at Milagrow SME Conference
Presentation at Milagrow SME Conference
rajeshjain
Ā 
Lecture 10 Image Format
Lecture 10  Image FormatLecture 10  Image Format
Lecture 10 Image Format
Sur College of Applied Sciences
Ā 
Ad

Similar to Lecture2 CSS 2 (20)

Css class-02
Css class-02Css class-02
Css class-02
Md Ali Hossain
Ā 
Basic css
Basic cssBasic css
Basic css
Gopinath Ambothi
Ā 
Cascading Style Sheets - Part 01
Cascading Style Sheets - Part 01Cascading Style Sheets - Part 01
Cascading Style Sheets - Part 01
Hatem Mahmoud
Ā 
CSS
CSSCSS
CSS
Akila Iroshan
Ā 
An Introduction to CSS
An Introduction to CSSAn Introduction to CSS
An Introduction to CSS
John Catterfeld
Ā 
Introduction to Web Development.pptx
Introduction to Web Development.pptxIntroduction to Web Development.pptx
Introduction to Web Development.pptx
GDSCVJTI
Ā 
Introduction to Web Development.pptx
Introduction to Web Development.pptxIntroduction to Web Development.pptx
Introduction to Web Development.pptx
Alisha Kamat
Ā 
Introduction to Web Development.pptx
Introduction to Web Development.pptxIntroduction to Web Development.pptx
Introduction to Web Development.pptx
Alisha Kamat
Ā 
css-tutorial
css-tutorialcss-tutorial
css-tutorial
tutorialsruby
Ā 
css-tutorial
css-tutorialcss-tutorial
css-tutorial
tutorialsruby
Ā 
CSS Basic and Common Errors
CSS Basic and Common ErrorsCSS Basic and Common Errors
CSS Basic and Common Errors
Hock Leng PUAH
Ā 
CSS3 and Selectors
CSS3 and SelectorsCSS3 and Selectors
CSS3 and Selectors
Rachel Andrew
Ā 
CSS Foundations, pt 2
CSS Foundations, pt 2CSS Foundations, pt 2
CSS Foundations, pt 2
Shawn Calvert
Ā 
Designing for the web - 101
Designing for the web - 101Designing for the web - 101
Designing for the web - 101
Ashraf Hamdy
Ā 
Front End Good Practices
Front End Good PracticesFront End Good Practices
Front End Good Practices
Hernan Mammana
Ā 
css v1 guru
css v1 gurucss v1 guru
css v1 guru
GuruPada Das
Ā 
CSS3 Refresher
CSS3 RefresherCSS3 Refresher
CSS3 Refresher
Ivano Malavolta
Ā 
Make Css easy(part:2) : easy tips for css(part:2)
Make Css easy(part:2) : easy tips for css(part:2)Make Css easy(part:2) : easy tips for css(part:2)
Make Css easy(part:2) : easy tips for css(part:2)
shabab shihan
Ā 
CSS memo
CSS memo CSS memo
CSS memo
VDMK
Ā 
Pfnp slides
Pfnp slidesPfnp slides
Pfnp slides
William Myers
Ā 
Cascading Style Sheets - Part 01
Cascading Style Sheets - Part 01Cascading Style Sheets - Part 01
Cascading Style Sheets - Part 01
Hatem Mahmoud
Ā 
An Introduction to CSS
An Introduction to CSSAn Introduction to CSS
An Introduction to CSS
John Catterfeld
Ā 
Introduction to Web Development.pptx
Introduction to Web Development.pptxIntroduction to Web Development.pptx
Introduction to Web Development.pptx
GDSCVJTI
Ā 
Introduction to Web Development.pptx
Introduction to Web Development.pptxIntroduction to Web Development.pptx
Introduction to Web Development.pptx
Alisha Kamat
Ā 
Introduction to Web Development.pptx
Introduction to Web Development.pptxIntroduction to Web Development.pptx
Introduction to Web Development.pptx
Alisha Kamat
Ā 
CSS Basic and Common Errors
CSS Basic and Common ErrorsCSS Basic and Common Errors
CSS Basic and Common Errors
Hock Leng PUAH
Ā 
CSS3 and Selectors
CSS3 and SelectorsCSS3 and Selectors
CSS3 and Selectors
Rachel Andrew
Ā 
CSS Foundations, pt 2
CSS Foundations, pt 2CSS Foundations, pt 2
CSS Foundations, pt 2
Shawn Calvert
Ā 
Designing for the web - 101
Designing for the web - 101Designing for the web - 101
Designing for the web - 101
Ashraf Hamdy
Ā 
Front End Good Practices
Front End Good PracticesFront End Good Practices
Front End Good Practices
Hernan Mammana
Ā 
Make Css easy(part:2) : easy tips for css(part:2)
Make Css easy(part:2) : easy tips for css(part:2)Make Css easy(part:2) : easy tips for css(part:2)
Make Css easy(part:2) : easy tips for css(part:2)
shabab shihan
Ā 
CSS memo
CSS memo CSS memo
CSS memo
VDMK
Ā 
Ad

More from Sur College of Applied Sciences (8)

Lecture11 A Image
Lecture11 A ImageLecture11 A Image
Lecture11 A Image
Sur College of Applied Sciences
Ā 
Lecture 11 B Security
Lecture 11 B SecurityLecture 11 B Security
Lecture 11 B Security
Sur College of Applied Sciences
Ā 
Accessibility Usability Professional Summry
Accessibility Usability Professional SummryAccessibility Usability Professional Summry
Accessibility Usability Professional Summry
Sur College of Applied Sciences
Ā 
Lecture 8 Video
Lecture 8 VideoLecture 8 Video
Lecture 8 Video
Sur College of Applied Sciences
Ā 
Lecture 5 XML
Lecture 5  XMLLecture 5  XML
Lecture 5 XML
Sur College of Applied Sciences
Ā 
Lecture2 CSS 3
Lecture2   CSS 3Lecture2   CSS 3
Lecture2 CSS 3
Sur College of Applied Sciences
Ā 
Lecture2 CSS1
Lecture2  CSS1Lecture2  CSS1
Lecture2 CSS1
Sur College of Applied Sciences
Ā 
Navigation1 A
Navigation1 ANavigation1 A
Navigation1 A
Sur College of Applied Sciences
Ā 

Recently uploaded (20)

Gibson "Secrets to Changing Behaviour in Scholarly Communication: A 2025 NISO...
Gibson "Secrets to Changing Behaviour in Scholarly Communication: A 2025 NISO...Gibson "Secrets to Changing Behaviour in Scholarly Communication: A 2025 NISO...
Gibson "Secrets to Changing Behaviour in Scholarly Communication: A 2025 NISO...
National Information Standards Organization (NISO)
Ā 
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition IILDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDM & Mia eStudios
Ā 
june 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptxjune 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptx
roger malina
Ā 
What are the benefits that dance brings?
What are the benefits that dance brings?What are the benefits that dance brings?
What are the benefits that dance brings?
memi27
Ā 
Final Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptxFinal Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptx
bobby205207
Ā 
TV Shows and web-series quiz | QUIZ CLUB OF PSGCAS | 13TH MARCH 2025
TV Shows and web-series quiz | QUIZ CLUB OF PSGCAS | 13TH MARCH 2025TV Shows and web-series quiz | QUIZ CLUB OF PSGCAS | 13TH MARCH 2025
TV Shows and web-series quiz | QUIZ CLUB OF PSGCAS | 13TH MARCH 2025
Quiz Club of PSG College of Arts & Science
Ā 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle SchoolExploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
Ā 
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptxRai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Dr. Ravi Shankar Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
Ā 
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti MpdBasic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Restu Bias Primandhika
Ā 
Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.
jmansha170
Ā 
How to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 SalesHow to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 Sales
Celine George
Ā 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptxAnalysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
Ā 
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
GeorgeDiamandis11
Ā 
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
Quiz Club of PSG College of Arts & Science
Ā 
Optimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptxOptimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptx
UrmiPrajapati3
Ā 
Capitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptxCapitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptx
CapitolTechU
Ā 
Hemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptxHemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptx
Arshad Shaikh
Ā 
Rose Cultivation Practices by Kushal Lamichhane.pdf
Rose Cultivation Practices by Kushal Lamichhane.pdfRose Cultivation Practices by Kushal Lamichhane.pdf
Rose Cultivation Practices by Kushal Lamichhane.pdf
kushallamichhame
Ā 
Unit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdfUnit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdf
KRUTIKA CHANNE
Ā 
Respiratory System , Urinary System
Respiratory  System , Urinary SystemRespiratory  System , Urinary System
Respiratory System , Urinary System
RushiMandali
Ā 
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition IILDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDM & Mia eStudios
Ā 
june 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptxjune 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptx
roger malina
Ā 
What are the benefits that dance brings?
What are the benefits that dance brings?What are the benefits that dance brings?
What are the benefits that dance brings?
memi27
Ā 
Final Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptxFinal Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptx
bobby205207
Ā 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle SchoolExploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
Ā 
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti MpdBasic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Restu Bias Primandhika
Ā 
Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.
jmansha170
Ā 
How to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 SalesHow to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 Sales
Celine George
Ā 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptxAnalysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
Ā 
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
GeorgeDiamandis11
Ā 
Optimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptxOptimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptx
UrmiPrajapati3
Ā 
Capitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptxCapitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptx
CapitolTechU
Ā 
Hemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptxHemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptx
Arshad Shaikh
Ā 
Rose Cultivation Practices by Kushal Lamichhane.pdf
Rose Cultivation Practices by Kushal Lamichhane.pdfRose Cultivation Practices by Kushal Lamichhane.pdf
Rose Cultivation Practices by Kushal Lamichhane.pdf
kushallamichhame
Ā 
Unit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdfUnit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdf
KRUTIKA CHANNE
Ā 
Respiratory System , Urinary System
Respiratory  System , Urinary SystemRespiratory  System , Urinary System
Respiratory System , Urinary System
RushiMandali
Ā 

Lecture2 CSS 2

  • 1. Lecture 2: CSS II SFDV2001 Web Development
  • 2. The Box Model In CSS every element in your HTML file is contained within a rectangular box. There are four main components to this box: Content Margin Padding Border Additionally there a couple of background components: background colour background image
  • 3. Image source: http://www.hicksdesign.co.uk/boxmodel/
  • 4. The Box Model Margins are always transparent. Padding is the space between the content and the border. Background colour and/or image extend throughout the box model to the border. If a style of border used has gaps in it (e.g. dashed), the background shows through those gaps. The background of the parent element shows through the margin area of the box.
  • 5. Width The width set for an element is the width of the content . Padding, border and margin are additional to this width. h1{ width: 300px; padding: 5px; border: solid 10px #ff69b4; margin: 10px; } Total width on page for this element = 350 pixels Unless your IE: IE implements the box model incorrectly.
  • 7. IE 5 (Mac) Safari Firefox
  • 9. Solutions There are hacks to combat many of the flaws in IE’s CSS rendering. Most exploit other IE bugs to provide workarounds. The Box Model hack (by Tantek Ƈelik) width: 350px; voice-family:ā€\ā€}\ā€ā€; voice-family: inherit; width: 300px; IE doesn’t see the second width specification.
  • 10. Selectors Recap: selector{ property: value; } There are many different kinds of selectors: Standard element selectors Contextual selectors Class selectors ID selectors Pseudoselectors
  • 11. Element selectors H1{ color: #456678; } You can group selectors: H1, p, li{ color: #456678; } You can affect any element using the universal ( * ) selector.
  • 12. Contextual Selectors Allow you to affect elements based on their context. That is, their relationship to other elements. Descendant selectors Elements that are contained within other elements: ul li{ color: #456678; } ul li a{ color: #456678; }
  • 13. Contextual Selectors Child Selectors Similar to descendant selectors but it target only a direct child of an element: p > em{ color: #456678; }
  • 14. Contextual Selectors Adjacent sibling selectors H1 + p{ margin-left: 5%; } Affects an element that comes immediately after another. In the above example the first paragraph after a top-level heading will be indented.
  • 15. Class and ID selectors You can’t always style every element you want to with the standard selectors available and some times you need to make your own. There are two kinds of ā€œcustom-madeā€ selectors: class and ID . Class is used for a style that you may wish to use multiple times in a single html file. ID is used for a style you wish to be unique in any one html file. You must set the class or ID in your HTML code.
  • 16. Class and ID selectors IDs take care of unique structural elements: Class is used for elements that are used multiple times : Heading Navigation Footer
  • 17. Ā 
  • 18. Class and ID selectors In your style sheet: Class p.question{ color: navy; } Or .question{ color: navy; }
  • 19. Class and ID selectors In your style sheet: ID Div#footer{ border-top: solid 1px #555555; font-size: smaller; } Or #footer{ border-top: solid 1px #555555; font-size: smaller; }
  • 20. Class and ID selectors Resist the temptation to make everything a class. Make sure your id and class names are descriptive. ā€œnavigationā€ is descriptive of the function of the selector rather than the style. ā€œredā€ is descriptive of a style - styles change. If you can use a contextual selector or the like instead of a class or ID, do so.
  • 21. Pseudoselectors Some things that you want to style in an html document are not possible to represent with standard element selectors because there is no element in your HTML document to represent them. Different link states - visited, unvisited etc. are good examples. Pseudoselectors enable you to identify these portions of elements. Pseudoselectors are identified in your CSS using a colon. a:link
  • 22. Pseudoselectors - Anchors Pseudoselectors are most commonly used to influence different link states. a:link a:visited a:hover a:active In transitional code the equivalents are the link , vlink and alink attributes of body. In CSS you get an extra link state (hover) and you can influence any aspect of a links style, not just colour.
  • 23. Pseudoselectors - Anchors a:link{ text-decoration: none; ... } a:visited{ color:#555555; ... } a:hover{ text-decoration: underline; } a:active{ color:#f6dc3b; ... }
  • 24. Pseudoselectors - Anchors Anchor pseudoselectors should appear in your CSS in the order: a a:link a:visited a:hover a:active If you don't, they may not function as they should. Putting : link last for example would override the : hover and : active states.
  • 25. Other pseudoselectors There are other pseudoselectors, but they aren't as commonly used as those associated with anchors because of poor browser support. :focus :first-child :first-line :first-letter :before :after :first-line and :first-letter are currently the only ones of this list that have any reasonable browser support.
  • 26. Block-level and Inline elements In html there are block elements and inline elements. The distinction between the two is important for how they may be nested. You know from transitional code that <font> tags only validate when used inside <p> tags. This is because <font> is an inline element and <p> is a block level element. Block-level elements can contain other block-level elements and inline elements. Inline elements can only contain content and other inline elements.
  • 27. Ā 
  • 28. Block-Level and Inline in CSS CSS allows you to explicitly state if an element is block-level or inline. BUT! These have nothing to do with the structure of your HTML and will not change the rules of validation. The notions of block-level and inline in CSS are presentation concepts only. display: block; display: inline;
  • 29. Ā 
  • 30. Ā 
  • 31. Recommended sites: Hicks Design Box Model diagram: http://www.hicksdesign.co.uk/3dboxmodel/ Interactive Box Model diagram: http://www.redmelon.net/tstme/box_model/ W3C's Box Model description: http://www.w3.org/TR/REC-CSS2/box.html Tantek Ƈelik's Box Model hack: http://tantek.com/CSS/Examples/boxmodelhack.html Further reading: Web Design in a Nutshell, 3rd Edition by Jennifer Niederst Robbins

Editor's Notes

  • #5: Show boxModel.html
  • #7: Top = doctype - ā€œstandards modeā€ As pages will appear in IE 6 and up with a doctype Bottom = no doctype - ā€œquirks modeā€ As pages appear in IE 5 and prior and for files without the right doctype. In version 6, Microsoft addressed this issue by implementing the W3C box model, if &amp;quot;standards mode&amp;quot; was enabled, which is done by defining a supported DOCTYPE on the first line of the HTML output.
  • #10: The &amp;quot;box model hack&amp;quot; developed by Tantek Ƈelik . Developed during his time at Microsoft working on Internet Explorer for the Macintosh, which is not affected by the bug — involves specifying a width for Internet Explorer for Windows which is then over-ridden by another width specification. This second specification is hidden from Internet Explorer for Windows by exploiting a bug in the way that browser parses CSS rules. width: 350px; - Width for IE voice-family:ā€ā€}ā€ā€; - IE is tricked into thinking rule has finished voice-family: inherit; - voice-family is reset for any browser that understands the property width: 300px; - the &amp;quot;real&amp;quot; width is set for all other browsers.
  • #11: Also attribute selectors but these are so poorly supported at present that I’m not going to talk about them here.
  • #14: First em is affected. Second is not.
  • #23: Don&apos;t forget plain a
  • #25: a
  • #26: Focus - can be applied to any element but in the few browsers that offer any support for it, generally only form elements can make use of it. Firstchild - as it suggests - e.g. Li:first-child - targets the first li of a list. Before and after allow for generated content to be inserted before or after an element: Blockquote:before{content:&amp;quot;&amp;#8220;&amp;quot; font-size: 24px} Blockquote:after{content:&amp;quot;&amp;#8220;&amp;quot; font-size: 24px} There is also :lang(ab).