SlideShare a Scribd company logo
CSS
// Styling the web since 1994
• Goal of HTML is to have a clear separation between document
structure and document presentation and so CSS is born
CSSfying the web: Inline
<p style="color: red">text</p>
• Pros
• Quick addition of styles
• Full control of style at the element declaration viz. Style applied
inline cannot be altered by styles applied using other ways.
Example
• Cons
• Reusability/maintainability of styles is not possible since they are
declared inline to the element
• If the color red has to be applied to another <p> element, it has to
be re-declared using style attribute
• Deviating from the Goal of HTML documents’ content and
presentation
CSSfying the web: Embedded
<!DOCTYPE html>
<html>
<head>
<title>CSS
Example</title>
<style>
p {
color: red;
}
a {
color: blue;
}
</style>
...
• Pros
• All styles are at one place which
gives a quick understanding of
presentation of the application
• Cons
• Reusability is achieved but only
to an extent
• Lets consider an application
having multiple pages with
multiple forms.
Submit button in a form has to
look the same through out the
application.
Since embedded styles are
declared within a page, they have
to be duplicated for other pages
• Deviating from the goal of
content and presentation
separation. Grouping is
achieved yet interfering with
the content.
CSSfying the web: External
// style.css
p {
color: red;
}
a {
color: blue;
}
// html file – see link
<!DOCTYPE html>
<html>
<head>
<title>CSS Example</title>
<link rel="stylesheet"
href="style.css">
...
• Pros
• Grouping of styles
• Modularization
• Reusability of styles
• In sync with the goal
• Cons
• No cons for the scope of this session
;)
Selectors
• To style multiple elements at once, we can use selectors
• Mainly there are 3 different kinds of selectors
• Tag selectors – p, div, span, etc.
• Used for html tags or any custom tags
• Id selectors – #container, #footer, #header, etc.
• Used for any html elements with id defined as
<p id="footer">text</p>
• Class selectors – .nav-link, .submit-btn, .icon, etc.
• Used for any html elements with class defined as
<button class="submit-btn">Submit</button>
• Example.
p {
color: red;
}
#footer {
color: grey;
}
.submit-btn {
background-color: blue;
}
Selectors contd…
• Along with aforementioned selectors, there are other selectors which
are used in different purposes
• Attribute selectors
• a[target=‘_blank’]
• Pseudo selectors
• :first-child
• :hover
• :focus
• …
• Before & After selectors
• ::before
• ::after
• Descendant & Child selectors
• p span  for any span inside p tag
• p > span  for immediate child span inside p tag
• Adjacent (sibling) selectors
• p + div  when p and div are siblings
• Example.
Box Model
• Every element in HTML follows CSS box model
• Width of the element is
width of <content> + padding-left + padding-right + border-left-
width + border-right-width + margin-left + margin-right
• Similarly, height of the element is
height of <content> + padding-top + padding-bottom + border-top-
width + border-bottom-width + margin-top + margin-bottom
CSS Positioning
• Types
• Static
• Relative
• Absolute
• Fixed
• Example
CSS Specificity
• If two (or more) conflicting CSS rules point to the same element, there are some
basic rules that a browser follows to determine which one is most specific and
therefore wins out
• The actual specificity of a group of nested selectors takes some calculating:
• every ID selector (“#whatever”) a value of 100,
• every class selector(“.whatever”) a value of 10 and
• every HTML selector (“whatever”) a value of 1.
Then you add them all up for the specificity value
• Example:
• p has a specificity of 1 (1 HTML selector)
• div p has a specificity of 2 (2 HTML selectors, 1+1)
• .tree has a specificity of 10 (1 class selector)
• div p.tree has a specificity of 12 (2 HTML selectors + a class selector, 1+1+10)
• #baobab has a specificity of 100 (1 id selector)
• body #content .alternative p has a specificity of 112 (HTML selector + id selector +
class selector + HTML selector, 1+100+10+1)
• If the selectors are the same then the last one will always take precedence
• Example
• Reference
CSS Examples
• Display
• Positioning
• Navigation
• Shape
• Shadow
• Animation, Animation-2
• Media-Queries
• Before & After
• Sphere
Best practices
• Modularize CSS into multiple files at design time if possible.
E.g., common CSS, module1 CSS, etc.
• Create own sub-language for CSS
• “footer-btn” class for a button which is in footer, etc.
• [HTML] Document content should convey semantic meaning
• Older browsers struggle with and get carried away with tables
and can seriously damage your accessibility.
• If you have tabular data, then, it should be arranged in HTML table
• Responsiveness
• Lengths
• Using media-queries for multiple screens
• https://github.com/bendc/frontend-guidelines
• http://caniuse.com/
References
• http://www.w3.org/Style/LieBos2e/history/Overview.html
• http://www.w3.org/TR/CSS21/selector.html%23id-selectors
• http://www.htmldog.com/guides/css/intermediate/specificity
• https://www.futurehosting.com/blog/web-design-basics-rem-
vs-em-vs-px-sizing-elements-in-css
• www.barelyfitz.com/screencast/html-training/css/positioning

More Related Content

What's hot

CSS Basics part One
CSS Basics part OneCSS Basics part One
CSS Basics part One
M Ashraful Islam Jewel
 
css.ppt
css.pptcss.ppt
css.ppt
bhasula
 
Cascading Style Sheets - CSS
Cascading Style Sheets - CSSCascading Style Sheets - CSS
Cascading Style Sheets - CSS
Sun Technlogies
 
Web Development - Lecture 3
Web Development - Lecture 3Web Development - Lecture 3
Web Development - Lecture 3
Syed Shahzaib Sohail
 
HTML Lists & Llinks
HTML Lists & LlinksHTML Lists & Llinks
HTML Lists & Llinks
Nisa Soomro
 
Types of Selectors (HTML)
Types of Selectors (HTML)Types of Selectors (HTML)
Types of Selectors (HTML)
Deanne Alcalde
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheets
smitha273566
 
Java 8 in action.Jinq
Java 8 in action.JinqJava 8 in action.Jinq
Java 8 in action.Jinq
Strannik_2013
 
Css types internal, external and inline (1)
Css types internal, external and inline (1)Css types internal, external and inline (1)
Css types internal, external and inline (1)
Webtech Learning
 
Web Engineering - Basic CSS Properties
Web Engineering - Basic CSS PropertiesWeb Engineering - Basic CSS Properties
Web Engineering - Basic CSS Properties
Nosheen Qamar
 
Basic css
Basic cssBasic css
Basic css
Gopinath Ambothi
 
Adobe Flash Actionscript language basics chapter-2
Adobe Flash Actionscript language basics chapter-2Adobe Flash Actionscript language basics chapter-2
Adobe Flash Actionscript language basics chapter-2
Nafis Ahmed
 
Html link and list tags
Html link and list tagsHtml link and list tags
Html link and list tags
Himanshu Pathak
 
Cmsc 100 xhtml and css
Cmsc 100 xhtml and cssCmsc 100 xhtml and css
Cmsc 100 xhtml and css
MaeEstherMaguadMaralit
 
Css syntax
Css   syntaxCss   syntax
Css syntax
AbhishekMondal42
 
Chapter 14: Box Model
Chapter 14: Box ModelChapter 14: Box Model
Chapter 14: Box Model
Steve Guinan
 
Chapter 12: CSS Part 2
Chapter 12: CSS Part 2Chapter 12: CSS Part 2
Chapter 12: CSS Part 2
Steve Guinan
 
CSS
CSSCSS
Images and Lists in HTML
Images and Lists in HTMLImages and Lists in HTML
Images and Lists in HTML
Marlon Jamera
 

What's hot (19)

CSS Basics part One
CSS Basics part OneCSS Basics part One
CSS Basics part One
 
css.ppt
css.pptcss.ppt
css.ppt
 
Cascading Style Sheets - CSS
Cascading Style Sheets - CSSCascading Style Sheets - CSS
Cascading Style Sheets - CSS
 
Web Development - Lecture 3
Web Development - Lecture 3Web Development - Lecture 3
Web Development - Lecture 3
 
HTML Lists & Llinks
HTML Lists & LlinksHTML Lists & Llinks
HTML Lists & Llinks
 
Types of Selectors (HTML)
Types of Selectors (HTML)Types of Selectors (HTML)
Types of Selectors (HTML)
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheets
 
Java 8 in action.Jinq
Java 8 in action.JinqJava 8 in action.Jinq
Java 8 in action.Jinq
 
Css types internal, external and inline (1)
Css types internal, external and inline (1)Css types internal, external and inline (1)
Css types internal, external and inline (1)
 
Web Engineering - Basic CSS Properties
Web Engineering - Basic CSS PropertiesWeb Engineering - Basic CSS Properties
Web Engineering - Basic CSS Properties
 
Basic css
Basic cssBasic css
Basic css
 
Adobe Flash Actionscript language basics chapter-2
Adobe Flash Actionscript language basics chapter-2Adobe Flash Actionscript language basics chapter-2
Adobe Flash Actionscript language basics chapter-2
 
Html link and list tags
Html link and list tagsHtml link and list tags
Html link and list tags
 
Cmsc 100 xhtml and css
Cmsc 100 xhtml and cssCmsc 100 xhtml and css
Cmsc 100 xhtml and css
 
Css syntax
Css   syntaxCss   syntax
Css syntax
 
Chapter 14: Box Model
Chapter 14: Box ModelChapter 14: Box Model
Chapter 14: Box Model
 
Chapter 12: CSS Part 2
Chapter 12: CSS Part 2Chapter 12: CSS Part 2
Chapter 12: CSS Part 2
 
CSS
CSSCSS
CSS
 
Images and Lists in HTML
Images and Lists in HTMLImages and Lists in HTML
Images and Lists in HTML
 

Similar to CSS Overview and Examples

Basic-CSS-tutorial
Basic-CSS-tutorialBasic-CSS-tutorial
Basic-CSS-tutorial
tutorialsruby
 
Basic css-tutorial
Basic css-tutorialBasic css-tutorial
Basic css-tutorial
mohamed ashraf
 
css v1 guru
css v1 gurucss v1 guru
css v1 guru
GuruPada Das
 
IT2255 Web Essentials - Unit II Web Designing
IT2255 Web Essentials - Unit II  Web DesigningIT2255 Web Essentials - Unit II  Web Designing
IT2255 Web Essentials - Unit II Web Designing
pkaviya
 
BITM3730 9-19.pptx
BITM3730 9-19.pptxBITM3730 9-19.pptx
BITM3730 9-19.pptx
MattMarino13
 
BITM3730 9-20.pptx
BITM3730 9-20.pptxBITM3730 9-20.pptx
BITM3730 9-20.pptx
MattMarino13
 
Ifi7174 lesson2
Ifi7174 lesson2Ifi7174 lesson2
Ifi7174 lesson2
Sónia
 
BITM3730 8-29.pptx
BITM3730 8-29.pptxBITM3730 8-29.pptx
BITM3730 8-29.pptx
MattMarino13
 
BITM3730 8-29.pptx
BITM3730 8-29.pptxBITM3730 8-29.pptx
BITM3730 8-29.pptx
MattMarino13
 
BITM3730 8-30.pptx
BITM3730 8-30.pptxBITM3730 8-30.pptx
BITM3730 8-30.pptx
MattMarino13
 
BITM3730 8-30.pptx
BITM3730 8-30.pptxBITM3730 8-30.pptx
BITM3730 8-30.pptx
MattMarino13
 
WEB TECHNOLOGY Unit-2.pptx
WEB TECHNOLOGY Unit-2.pptxWEB TECHNOLOGY Unit-2.pptx
WEB TECHNOLOGY Unit-2.pptx
karthiksmart21
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheets
smithaps4
 
Html and css
Html and cssHtml and css
Html and css
Sukrit Gupta
 
Intro to html, css & sass
Intro to html, css & sassIntro to html, css & sass
Intro to html, css & sass
Sean Wolfe
 
Make Css easy : easy tips for css
Make Css easy : easy tips for cssMake Css easy : easy tips for css
Make Css easy : easy tips for css
shabab shihan
 
Css
CssCss
CSS Introduction
CSS Introduction CSS Introduction
CSS Introduction
Thapar Institute
 
Kick start @ css
Kick start @ cssKick start @ css
Kick start @ css
Umesh Agarwal
 
Blackboard DevCon 2011 - Performance Considerations for Custom Theme Development
Blackboard DevCon 2011 - Performance Considerations for Custom Theme DevelopmentBlackboard DevCon 2011 - Performance Considerations for Custom Theme Development
Blackboard DevCon 2011 - Performance Considerations for Custom Theme Development
Noriaki Tatsumi
 

Similar to CSS Overview and Examples (20)

Basic-CSS-tutorial
Basic-CSS-tutorialBasic-CSS-tutorial
Basic-CSS-tutorial
 
Basic css-tutorial
Basic css-tutorialBasic css-tutorial
Basic css-tutorial
 
css v1 guru
css v1 gurucss v1 guru
css v1 guru
 
IT2255 Web Essentials - Unit II Web Designing
IT2255 Web Essentials - Unit II  Web DesigningIT2255 Web Essentials - Unit II  Web Designing
IT2255 Web Essentials - Unit II Web Designing
 
BITM3730 9-19.pptx
BITM3730 9-19.pptxBITM3730 9-19.pptx
BITM3730 9-19.pptx
 
BITM3730 9-20.pptx
BITM3730 9-20.pptxBITM3730 9-20.pptx
BITM3730 9-20.pptx
 
Ifi7174 lesson2
Ifi7174 lesson2Ifi7174 lesson2
Ifi7174 lesson2
 
BITM3730 8-29.pptx
BITM3730 8-29.pptxBITM3730 8-29.pptx
BITM3730 8-29.pptx
 
BITM3730 8-29.pptx
BITM3730 8-29.pptxBITM3730 8-29.pptx
BITM3730 8-29.pptx
 
BITM3730 8-30.pptx
BITM3730 8-30.pptxBITM3730 8-30.pptx
BITM3730 8-30.pptx
 
BITM3730 8-30.pptx
BITM3730 8-30.pptxBITM3730 8-30.pptx
BITM3730 8-30.pptx
 
WEB TECHNOLOGY Unit-2.pptx
WEB TECHNOLOGY Unit-2.pptxWEB TECHNOLOGY Unit-2.pptx
WEB TECHNOLOGY Unit-2.pptx
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheets
 
Html and css
Html and cssHtml and css
Html and css
 
Intro to html, css & sass
Intro to html, css & sassIntro to html, css & sass
Intro to html, css & sass
 
Make Css easy : easy tips for css
Make Css easy : easy tips for cssMake Css easy : easy tips for css
Make Css easy : easy tips for css
 
Css
CssCss
Css
 
CSS Introduction
CSS Introduction CSS Introduction
CSS Introduction
 
Kick start @ css
Kick start @ cssKick start @ css
Kick start @ css
 
Blackboard DevCon 2011 - Performance Considerations for Custom Theme Development
Blackboard DevCon 2011 - Performance Considerations for Custom Theme DevelopmentBlackboard DevCon 2011 - Performance Considerations for Custom Theme Development
Blackboard DevCon 2011 - Performance Considerations for Custom Theme Development
 

Recently uploaded

Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 

Recently uploaded (20)

Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 

CSS Overview and Examples

  • 1. CSS // Styling the web since 1994
  • 2. • Goal of HTML is to have a clear separation between document structure and document presentation and so CSS is born
  • 3. CSSfying the web: Inline <p style="color: red">text</p> • Pros • Quick addition of styles • Full control of style at the element declaration viz. Style applied inline cannot be altered by styles applied using other ways. Example • Cons • Reusability/maintainability of styles is not possible since they are declared inline to the element • If the color red has to be applied to another <p> element, it has to be re-declared using style attribute • Deviating from the Goal of HTML documents’ content and presentation
  • 4. CSSfying the web: Embedded <!DOCTYPE html> <html> <head> <title>CSS Example</title> <style> p { color: red; } a { color: blue; } </style> ... • Pros • All styles are at one place which gives a quick understanding of presentation of the application • Cons • Reusability is achieved but only to an extent • Lets consider an application having multiple pages with multiple forms. Submit button in a form has to look the same through out the application. Since embedded styles are declared within a page, they have to be duplicated for other pages • Deviating from the goal of content and presentation separation. Grouping is achieved yet interfering with the content.
  • 5. CSSfying the web: External // style.css p { color: red; } a { color: blue; } // html file – see link <!DOCTYPE html> <html> <head> <title>CSS Example</title> <link rel="stylesheet" href="style.css"> ... • Pros • Grouping of styles • Modularization • Reusability of styles • In sync with the goal • Cons • No cons for the scope of this session ;)
  • 6. Selectors • To style multiple elements at once, we can use selectors • Mainly there are 3 different kinds of selectors • Tag selectors – p, div, span, etc. • Used for html tags or any custom tags • Id selectors – #container, #footer, #header, etc. • Used for any html elements with id defined as <p id="footer">text</p> • Class selectors – .nav-link, .submit-btn, .icon, etc. • Used for any html elements with class defined as <button class="submit-btn">Submit</button> • Example. p { color: red; } #footer { color: grey; } .submit-btn { background-color: blue; }
  • 7. Selectors contd… • Along with aforementioned selectors, there are other selectors which are used in different purposes • Attribute selectors • a[target=‘_blank’] • Pseudo selectors • :first-child • :hover • :focus • … • Before & After selectors • ::before • ::after • Descendant & Child selectors • p span  for any span inside p tag • p > span  for immediate child span inside p tag • Adjacent (sibling) selectors • p + div  when p and div are siblings • Example.
  • 8. Box Model • Every element in HTML follows CSS box model • Width of the element is width of <content> + padding-left + padding-right + border-left- width + border-right-width + margin-left + margin-right • Similarly, height of the element is height of <content> + padding-top + padding-bottom + border-top- width + border-bottom-width + margin-top + margin-bottom
  • 9. CSS Positioning • Types • Static • Relative • Absolute • Fixed • Example
  • 10. CSS Specificity • If two (or more) conflicting CSS rules point to the same element, there are some basic rules that a browser follows to determine which one is most specific and therefore wins out • The actual specificity of a group of nested selectors takes some calculating: • every ID selector (“#whatever”) a value of 100, • every class selector(“.whatever”) a value of 10 and • every HTML selector (“whatever”) a value of 1. Then you add them all up for the specificity value • Example: • p has a specificity of 1 (1 HTML selector) • div p has a specificity of 2 (2 HTML selectors, 1+1) • .tree has a specificity of 10 (1 class selector) • div p.tree has a specificity of 12 (2 HTML selectors + a class selector, 1+1+10) • #baobab has a specificity of 100 (1 id selector) • body #content .alternative p has a specificity of 112 (HTML selector + id selector + class selector + HTML selector, 1+100+10+1) • If the selectors are the same then the last one will always take precedence • Example • Reference
  • 11. CSS Examples • Display • Positioning • Navigation • Shape • Shadow • Animation, Animation-2 • Media-Queries • Before & After • Sphere
  • 12. Best practices • Modularize CSS into multiple files at design time if possible. E.g., common CSS, module1 CSS, etc. • Create own sub-language for CSS • “footer-btn” class for a button which is in footer, etc. • [HTML] Document content should convey semantic meaning • Older browsers struggle with and get carried away with tables and can seriously damage your accessibility. • If you have tabular data, then, it should be arranged in HTML table • Responsiveness • Lengths • Using media-queries for multiple screens • https://github.com/bendc/frontend-guidelines • http://caniuse.com/
  • 13. References • http://www.w3.org/Style/LieBos2e/history/Overview.html • http://www.w3.org/TR/CSS21/selector.html%23id-selectors • http://www.htmldog.com/guides/css/intermediate/specificity • https://www.futurehosting.com/blog/web-design-basics-rem- vs-em-vs-px-sizing-elements-in-css • www.barelyfitz.com/screencast/html-training/css/positioning