SlideShare ist ein Scribd-Unternehmen logo
1 von 31
Styling HTML with CSS
1
Acknowledgements: www.w3schools.com
Computer Network & Web Tech (SET, JU)
What is CSS?
 CSS is a language that describes the style of an HTML document
 Describes how HTML elements should be displayed on screen
body {
background-color: lightblue;
}
h1 {
color: white;
text-align: center;
}
p {
font-family: verdana;
font-size: 20px;
} 2
Computer Network & Web Tech (SET, JU)
What is CSS?
 CSS stands for Cascading Style Sheets
 Saves a lot of work - can control the layout of multiple web
pages all at once
 Can be added to HTML in three ways:
 Inline  using style attribute in HTML elements
 Internal  using <style> element in <head> section
 External  Using an external stylesheet, stored in
external CSS file
3Computer Network & Web Tech (SET, JU)
Inline CSS
 Used to apply a unique style to a single html element using
‘style’ attribute of an HTML element
<h1 style=“color:blue;”> This is a Blue Heading </h1>
<table style="width:200 px" border>
4Computer Network & Web Tech (SET, JU)
Internal CSS
 Used to define style for a single HTML page
 Defined in the <head> section using <style> element
<head>
<style>
body { background-color: lightblue;}
h1 {color: white; text-align: center;}
p {color: red; font-family: verdana; font-size: 20px;}
</style>
</head>
5Computer Network & Web Tech (SET, JU)
External CSS
 Used to define style for many HTML pages
 With external CSS, one can change the look of an entire
website very quickly by changing a single file
 To use an external stylesheet, add a link to it in the header
page
<head>
<link rel=“stylesheet” type="text/css" href=“styles.css”>
</head>
6Computer Network & Web Tech (SET, JU)
External CSS (contd..)
 An external style-sheet can be written in any text editor , and
saved with a .CSS extension
 Must not contain any HTML code
body {
background-color: lightblue;
}
h1 {
color: white;
text-align: center;
}
p {
font-family: verdana;
font-size: 20px;
} 7Computer Network & Web Tech (SET, JU)
External Reference
(Absolute & Relative Path)
 External style sheets can be referenced with a full URL or with a path
relative to the current web page
A full URL to link to a style sheet:
<link rel="stylesheet" href="https://www.xyz.com/html/styles.css">
Link to a style sheet located in the html folder on the current web site:
<link rel="stylesheet" href="/html/styles.css">
Link to a style sheet located in the same folder as the current page:
link rel="stylesheet" href="styles.css">
Link to a style sheet located in a folder one level up from the current page:
<link rel="stylesheet" href=“../html/styles.css">
8Computer Network & Web Tech (SET, JU)
CSS Syntax
9Computer Network & Web Tech (SET, JU)
CSS Syntax
 A CSS rule-set consists of a selector and a declaration block
 Selector points to the HTML element to style
 Used to "find" (or select) HTML elements based on their element
name, id, class, attribute etc.
 Declaration block surrounded by curly braces
 Contains one or more declarations separated by semicolons
 Each declaration includes a CSS property name and a value,
separated by a colon
10Computer Network & Web Tech (SET, JU)
Element Selector
 Selector selects elements based on the element name
Eg. <h1> element in red color, and with centre-aligned text
<p> element in black color, and text using verdana font and size = 20px
h1 { color: red; text-align: center;}
p { color: black; font-family: verdana; font-size: 20px;}
11Computer Network & Web Tech (SET, JU)
Id Selector
 Uses the id attribute of an HTML element to select a specific element
 To define a specific style for one special element, add an id attribute
to the element:
<p id="p01">I am different</p>
then define a style for the element with the specific id:
#p01 {
color: blue;
}
 The id of an element should be unique within a page, so the id selector
is used to select one unique element
12
Computer Network & Web Tech (SET, JU)
Class Selector
 Selects elements with a specific class attribute
 To define a style for a type of special elements, add a class attribute to
corresponding elements in the page
<p class=“center"> I am different</p>
 To select elements with a specific class for styling, write a period (.)
character, followed by the name of the class in the stylesheet
With above definition, all HTML elements with class="center" will be red and
center-aligned
.center {
text-align: center;
color: red;
}
13Computer Network & Web Tech (SET, JU)
Class Selector (contd..)
 One can specify that only specific HTML elements should be affected
by a class (element + class)
 Eg. only <p> elements with class="center" will be center-aligned
 HTML elements can also refer to more than one class
p.center {
text-align: center;
color: red;
}
<p class=“center large” >
14Computer Network & Web Tech (SET, JU)
Grouping Selector
 For elements with same definition, selectors can be grouped together
to minimize code – separated by commas
h1, h2, p {
text-align: center;
color: red;
}
h1 {
color: white;
text-align: center;}
h2 {
color: white;
text-align: center;}
p {
color: white;
text-align: center; }
15Computer Network & Web Tech (SET, JU)
Styling Text
16Computer Network & Web Tech (SET, JU)
CSS Color and Fonts
 CSS color property defines the text color to be used
 CSS font-family property defines the font to be used
 CSS font-size property defines the text size to be used
Example
<style>
h1 {
color: blue;
font-family: verdana;
font-size: 300%;
}
p {
color: red;
font-family: courier;
font-size: 16 px; text-align:center;
}
</style> 17Computer Network & Web Tech (SET, JU)
Background Color
 The background-color property defines the background color
for an HTML element
 This example sets the background color for a page to
powderblue
<html>
<body style="background-color:powderblue;">
<p style="color:black;"> This is a para </p>
</body>
</html>
18Computer Network & Web Tech (SET, JU)
HTML Colors
19Computer Network & Web Tech (SET, JU)
HTML Colors
 Specified by color name or value (RGB, HEX, HSL, RGBA, HSLA)
Specification by Color Names
Examples
Background Color
<body style="background-color:powderblue;">
Text Color
<h1 style="color:red;">This is a heading</h1>
Border Color
<h1 style="border: 2px solid DodgerBlue;">Hello World</h1>
20Computer Network & Web Tech (SET, JU)
Color Value - RGB
 In HTML, a color can be specified as an RGB value, using this
formula:
rgb(red, green, blue)
 Each parameter (red, green, and blue) defines the intensity of the
color between 0 and 255
Examples
rgb (255,0,0)  red
rgb (0,255,0)  green
rgb(0,0,0)  black
rgb(255,255,255)  white
Shades of gray are often defined using equal values for all the 3 lightsources
21Computer Network & Web Tech (SET, JU)
Color Value - Hex
 Color value specified as a hexadecimal of the form #RRGGBB
 Each parameter (red, green, and blue) is defined as a hex value
representing its intensity between 00 and FF
Examples
#FF0000  red
#00FF00  green
#000000  black
#FFFFFF  white
22Computer Network & Web Tech (SET, JU)
Color Value - HSL
 In HTML, a color can be specified using hue, saturation, and lightness
(HSL) in the form
hsl(hue, saturation, lightness)
 Hue is a degree on the color wheel from 0 to 360. 0 is red, 120 is
green, and 240 is blue.
 Saturation is a % value, 0% means a complete shade of gray, 50% is
50% gray and 100% is the pure color, no shades of gray
 Lightness is also a percentage, 0% is black, 50% is neither light or
dark, 100% is white – how much light given to the color
 Shades of gray are often defined by setting the hue and saturation to
0, and adjust the lightness from 0% to 100% to get darker/lighter
shades
<h1 style="background-color:hsl(9, 100%, 64%);">...</h1>
23Computer Network & Web Tech (SET, JU)
Color Value – RGBA & HSLA
 RGBA color values are an extension of RGB color values with an
alpha channel - which specifies the opacity for a color
rgba(red, green, blue, alpha)
 HSLA color values are an extension of HSL color values with an
alpha channel - which specifies the opacity for a color
hsla(hue, saturation, lightness, alpha)
 The alpha parameter is a number between 0.0 (fully transparent)
and 1.0 (not transparent at all)
<h1 style="background-color:rgba(255, 99, 71, 0.5);">...</h1>
<h1 style="background-color:hsla(9, 100%, 64%, 0.5);">...</h1>
24Computer Network & Web Tech (SET, JU)
Border, Margins, Padding
25Computer Network & Web Tech (SET, JU)
Box Model: Border, Padding and Margin
 Content - The content of the box, where text and images appear
 Padding - Clears an area around the content
 Border - A border that goes around the padding and content
 Margin - Clears an area outside the border. The margin is transparent26Computer Network & Web Tech (SET, JU)
CSS Border, Padding and Margin
 CSS border property defines a border around an HTML element
p {
border: 1px solid powderblue;
}
 CSS padding property defines a padding (space) between the
text and the border
p {
border: 1px solid powderblue;
padding: 30px;
}
 CSS margin property defines a margin (space) outside the
border
p {
border: 1px solid powderblue;
margin: 50px;
} 27Computer Network & Web Tech (SET, JU)
Border
 If no border style defined, table displayed without borders
 Border can be defined for tables and also table cells and headers
 Border set using CSS border property
table, th, td {
border: 2px solid black;
border-collapse: collapse;
}
 CSS border property - border-collapse
 Border-style property specifies what kind of border to display – solid,
dotted, dashed, double, inset, outset
p.mix {border-style: dotted solid double;}
28Computer Network & Web Tech (SET, JU)
Cell Padding & Border Spacing
 Cell padding specifies the space between the cell content and its borders
 If padding not specified, table cells to be displayed without padding
 Padding set using CSS padding property
th, td {
padding: 15 px;
}
 Border spacing specifies the space between the cells
 Spacing specified using CSS border-spacing property
 No effect if border-collapse set
table {
border-spacing: 5 px;
}
29Computer Network & Web Tech (SET, JU)
Margin
 CSS margin properties are used to generate space around elements
 Set the size of the white space outside the border – top, bottom, left, right
p {
margin-top: 100px;
margin-bottom: 100px;
margin-right: 150px;
margin-left: 80px; }
p {
margin: 100px 150px 100px 80px;
}
4 values  top, right, bottom, left
3 values  top, right and left, bottom
2 values  top & bottom, right and left
30Computer Network & Web Tech (SET, JU)
Margin - Inherit
 CSS margin properties can be inherited from parent element
div.container {
border: 1px solid red;
margin-left: 100px;
}
p.one {
margin-left: inherit;
}
31Computer Network & Web Tech (SET, JU)

Weitere ähnliche Inhalte

Was ist angesagt? (20)

Css
CssCss
Css
 
Css2
Css2Css2
Css2
 
Css2
Css2Css2
Css2
 
Introduction to css by programmerblog.net
Introduction to css by programmerblog.netIntroduction to css by programmerblog.net
Introduction to css by programmerblog.net
 
Css
CssCss
Css
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
 
CSS Part I
CSS Part ICSS Part I
CSS Part I
 
CSS for Beginners
CSS for BeginnersCSS for Beginners
CSS for Beginners
 
How to create a html webpage using notepad
How to create a html webpage using notepadHow to create a html webpage using notepad
How to create a html webpage using notepad
 
CSS Cascade Style Sheet
CSS Cascade Style SheetCSS Cascade Style Sheet
CSS Cascade Style Sheet
 
Cascading style sheet
Cascading style sheetCascading style sheet
Cascading style sheet
 
Html training slide
Html training slideHtml training slide
Html training slide
 
Html starting
Html startingHtml starting
Html starting
 
cascading style sheet ppt
cascading style sheet pptcascading style sheet ppt
cascading style sheet ppt
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
 
CSS
CSSCSS
CSS
 
CSS Boc model
CSS Boc model CSS Boc model
CSS Boc model
 
HTML
HTML HTML
HTML
 
Web Design Course: CSS lecture 3
Web Design Course: CSS lecture 3Web Design Course: CSS lecture 3
Web Design Course: CSS lecture 3
 
WEB DEVELOPMENT
WEB DEVELOPMENTWEB DEVELOPMENT
WEB DEVELOPMENT
 

Ähnlich wie Html 3 (20)

Html 2
Html   2Html   2
Html 2
 
Web - CSS 1.pptx
Web - CSS 1.pptxWeb - CSS 1.pptx
Web - CSS 1.pptx
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
 
Chapter 4a cascade style sheet css
Chapter 4a cascade style sheet cssChapter 4a cascade style sheet css
Chapter 4a cascade style sheet css
 
David Weliver
David WeliverDavid Weliver
David Weliver
 
Css basics
Css basicsCss basics
Css basics
 
TUTORIAL DE CSS 2.0
TUTORIAL DE CSS 2.0TUTORIAL DE CSS 2.0
TUTORIAL DE CSS 2.0
 
WebDesigning.pptx
WebDesigning.pptxWebDesigning.pptx
WebDesigning.pptx
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 
Css introduction
Css  introductionCss  introduction
Css introduction
 
CSS_Day_ONE (W3schools)
CSS_Day_ONE (W3schools)CSS_Day_ONE (W3schools)
CSS_Day_ONE (W3schools)
 
Css tutorial
Css tutorialCss tutorial
Css tutorial
 
Web Programming-css.pptx
Web Programming-css.pptxWeb Programming-css.pptx
Web Programming-css.pptx
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
 
CSS.pdf
CSS.pdfCSS.pdf
CSS.pdf
 
Css
CssCss
Css
 
Css
CssCss
Css
 
html-css
html-csshtml-css
html-css
 
css-note.pptx
css-note.pptxcss-note.pptx
css-note.pptx
 

Mehr von pavishkumarsingh (18)

Xml 2
Xml  2 Xml  2
Xml 2
 
Xml 1
Xml 1Xml 1
Xml 1
 
Javascript 2
Javascript 2Javascript 2
Javascript 2
 
Javascript 1
Javascript 1Javascript 1
Javascript 1
 
Html 5
Html   5Html   5
Html 5
 
Html 4
Html   4Html   4
Html 4
 
Html 4
Html   4Html   4
Html 4
 
Html 1
Html 1Html 1
Html 1
 
Final action script
Final action scriptFinal action script
Final action script
 
Multimedia system
Multimedia systemMultimedia system
Multimedia system
 
Visual basic
Visual basicVisual basic
Visual basic
 
Human - compuTer interaction
Human  -  compuTer interactionHuman  -  compuTer interaction
Human - compuTer interaction
 
Multimedia system(OPEN DOCUMENT ARCHITECTURE AND INTERCHANGING FORMAT)
Multimedia system(OPEN DOCUMENT ARCHITECTURE AND INTERCHANGING FORMAT)Multimedia system(OPEN DOCUMENT ARCHITECTURE AND INTERCHANGING FORMAT)
Multimedia system(OPEN DOCUMENT ARCHITECTURE AND INTERCHANGING FORMAT)
 
Authoring metaphors
Authoring metaphorsAuthoring metaphors
Authoring metaphors
 
Final action script for visual basic
Final action script for visual basicFinal action script for visual basic
Final action script for visual basic
 
Cognitive aspects in human computer interaction
Cognitive aspects in human computer interactionCognitive aspects in human computer interaction
Cognitive aspects in human computer interaction
 
list script and flowchart
list script and flowchartlist script and flowchart
list script and flowchart
 
Networks
Networks   Networks
Networks
 

Kürzlich hochgeladen

lifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptxlifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptxsomshekarkn64
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the weldingMuhammadUzairLiaqat
 
Piping Basic stress analysis by engineering
Piping Basic stress analysis by engineeringPiping Basic stress analysis by engineering
Piping Basic stress analysis by engineeringJuanCarlosMorales19600
 
Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsSachinPawar510423
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
Solving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptSolving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptJasonTagapanGulla
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substationstephanwindworld
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncssuser2ae721
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...121011101441
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - GuideGOPINATHS437943
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 

Kürzlich hochgeladen (20)

lifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptxlifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptx
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the welding
 
Piping Basic stress analysis by engineering
Piping Basic stress analysis by engineeringPiping Basic stress analysis by engineering
Piping Basic stress analysis by engineering
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documents
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
Solving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptSolving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.ppt
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substation
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - Guide
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 

Html 3

  • 1. Styling HTML with CSS 1 Acknowledgements: www.w3schools.com Computer Network & Web Tech (SET, JU)
  • 2. What is CSS?  CSS is a language that describes the style of an HTML document  Describes how HTML elements should be displayed on screen body { background-color: lightblue; } h1 { color: white; text-align: center; } p { font-family: verdana; font-size: 20px; } 2 Computer Network & Web Tech (SET, JU)
  • 3. What is CSS?  CSS stands for Cascading Style Sheets  Saves a lot of work - can control the layout of multiple web pages all at once  Can be added to HTML in three ways:  Inline  using style attribute in HTML elements  Internal  using <style> element in <head> section  External  Using an external stylesheet, stored in external CSS file 3Computer Network & Web Tech (SET, JU)
  • 4. Inline CSS  Used to apply a unique style to a single html element using ‘style’ attribute of an HTML element <h1 style=“color:blue;”> This is a Blue Heading </h1> <table style="width:200 px" border> 4Computer Network & Web Tech (SET, JU)
  • 5. Internal CSS  Used to define style for a single HTML page  Defined in the <head> section using <style> element <head> <style> body { background-color: lightblue;} h1 {color: white; text-align: center;} p {color: red; font-family: verdana; font-size: 20px;} </style> </head> 5Computer Network & Web Tech (SET, JU)
  • 6. External CSS  Used to define style for many HTML pages  With external CSS, one can change the look of an entire website very quickly by changing a single file  To use an external stylesheet, add a link to it in the header page <head> <link rel=“stylesheet” type="text/css" href=“styles.css”> </head> 6Computer Network & Web Tech (SET, JU)
  • 7. External CSS (contd..)  An external style-sheet can be written in any text editor , and saved with a .CSS extension  Must not contain any HTML code body { background-color: lightblue; } h1 { color: white; text-align: center; } p { font-family: verdana; font-size: 20px; } 7Computer Network & Web Tech (SET, JU)
  • 8. External Reference (Absolute & Relative Path)  External style sheets can be referenced with a full URL or with a path relative to the current web page A full URL to link to a style sheet: <link rel="stylesheet" href="https://www.xyz.com/html/styles.css"> Link to a style sheet located in the html folder on the current web site: <link rel="stylesheet" href="/html/styles.css"> Link to a style sheet located in the same folder as the current page: link rel="stylesheet" href="styles.css"> Link to a style sheet located in a folder one level up from the current page: <link rel="stylesheet" href=“../html/styles.css"> 8Computer Network & Web Tech (SET, JU)
  • 9. CSS Syntax 9Computer Network & Web Tech (SET, JU)
  • 10. CSS Syntax  A CSS rule-set consists of a selector and a declaration block  Selector points to the HTML element to style  Used to "find" (or select) HTML elements based on their element name, id, class, attribute etc.  Declaration block surrounded by curly braces  Contains one or more declarations separated by semicolons  Each declaration includes a CSS property name and a value, separated by a colon 10Computer Network & Web Tech (SET, JU)
  • 11. Element Selector  Selector selects elements based on the element name Eg. <h1> element in red color, and with centre-aligned text <p> element in black color, and text using verdana font and size = 20px h1 { color: red; text-align: center;} p { color: black; font-family: verdana; font-size: 20px;} 11Computer Network & Web Tech (SET, JU)
  • 12. Id Selector  Uses the id attribute of an HTML element to select a specific element  To define a specific style for one special element, add an id attribute to the element: <p id="p01">I am different</p> then define a style for the element with the specific id: #p01 { color: blue; }  The id of an element should be unique within a page, so the id selector is used to select one unique element 12 Computer Network & Web Tech (SET, JU)
  • 13. Class Selector  Selects elements with a specific class attribute  To define a style for a type of special elements, add a class attribute to corresponding elements in the page <p class=“center"> I am different</p>  To select elements with a specific class for styling, write a period (.) character, followed by the name of the class in the stylesheet With above definition, all HTML elements with class="center" will be red and center-aligned .center { text-align: center; color: red; } 13Computer Network & Web Tech (SET, JU)
  • 14. Class Selector (contd..)  One can specify that only specific HTML elements should be affected by a class (element + class)  Eg. only <p> elements with class="center" will be center-aligned  HTML elements can also refer to more than one class p.center { text-align: center; color: red; } <p class=“center large” > 14Computer Network & Web Tech (SET, JU)
  • 15. Grouping Selector  For elements with same definition, selectors can be grouped together to minimize code – separated by commas h1, h2, p { text-align: center; color: red; } h1 { color: white; text-align: center;} h2 { color: white; text-align: center;} p { color: white; text-align: center; } 15Computer Network & Web Tech (SET, JU)
  • 16. Styling Text 16Computer Network & Web Tech (SET, JU)
  • 17. CSS Color and Fonts  CSS color property defines the text color to be used  CSS font-family property defines the font to be used  CSS font-size property defines the text size to be used Example <style> h1 { color: blue; font-family: verdana; font-size: 300%; } p { color: red; font-family: courier; font-size: 16 px; text-align:center; } </style> 17Computer Network & Web Tech (SET, JU)
  • 18. Background Color  The background-color property defines the background color for an HTML element  This example sets the background color for a page to powderblue <html> <body style="background-color:powderblue;"> <p style="color:black;"> This is a para </p> </body> </html> 18Computer Network & Web Tech (SET, JU)
  • 19. HTML Colors 19Computer Network & Web Tech (SET, JU)
  • 20. HTML Colors  Specified by color name or value (RGB, HEX, HSL, RGBA, HSLA) Specification by Color Names Examples Background Color <body style="background-color:powderblue;"> Text Color <h1 style="color:red;">This is a heading</h1> Border Color <h1 style="border: 2px solid DodgerBlue;">Hello World</h1> 20Computer Network & Web Tech (SET, JU)
  • 21. Color Value - RGB  In HTML, a color can be specified as an RGB value, using this formula: rgb(red, green, blue)  Each parameter (red, green, and blue) defines the intensity of the color between 0 and 255 Examples rgb (255,0,0)  red rgb (0,255,0)  green rgb(0,0,0)  black rgb(255,255,255)  white Shades of gray are often defined using equal values for all the 3 lightsources 21Computer Network & Web Tech (SET, JU)
  • 22. Color Value - Hex  Color value specified as a hexadecimal of the form #RRGGBB  Each parameter (red, green, and blue) is defined as a hex value representing its intensity between 00 and FF Examples #FF0000  red #00FF00  green #000000  black #FFFFFF  white 22Computer Network & Web Tech (SET, JU)
  • 23. Color Value - HSL  In HTML, a color can be specified using hue, saturation, and lightness (HSL) in the form hsl(hue, saturation, lightness)  Hue is a degree on the color wheel from 0 to 360. 0 is red, 120 is green, and 240 is blue.  Saturation is a % value, 0% means a complete shade of gray, 50% is 50% gray and 100% is the pure color, no shades of gray  Lightness is also a percentage, 0% is black, 50% is neither light or dark, 100% is white – how much light given to the color  Shades of gray are often defined by setting the hue and saturation to 0, and adjust the lightness from 0% to 100% to get darker/lighter shades <h1 style="background-color:hsl(9, 100%, 64%);">...</h1> 23Computer Network & Web Tech (SET, JU)
  • 24. Color Value – RGBA & HSLA  RGBA color values are an extension of RGB color values with an alpha channel - which specifies the opacity for a color rgba(red, green, blue, alpha)  HSLA color values are an extension of HSL color values with an alpha channel - which specifies the opacity for a color hsla(hue, saturation, lightness, alpha)  The alpha parameter is a number between 0.0 (fully transparent) and 1.0 (not transparent at all) <h1 style="background-color:rgba(255, 99, 71, 0.5);">...</h1> <h1 style="background-color:hsla(9, 100%, 64%, 0.5);">...</h1> 24Computer Network & Web Tech (SET, JU)
  • 25. Border, Margins, Padding 25Computer Network & Web Tech (SET, JU)
  • 26. Box Model: Border, Padding and Margin  Content - The content of the box, where text and images appear  Padding - Clears an area around the content  Border - A border that goes around the padding and content  Margin - Clears an area outside the border. The margin is transparent26Computer Network & Web Tech (SET, JU)
  • 27. CSS Border, Padding and Margin  CSS border property defines a border around an HTML element p { border: 1px solid powderblue; }  CSS padding property defines a padding (space) between the text and the border p { border: 1px solid powderblue; padding: 30px; }  CSS margin property defines a margin (space) outside the border p { border: 1px solid powderblue; margin: 50px; } 27Computer Network & Web Tech (SET, JU)
  • 28. Border  If no border style defined, table displayed without borders  Border can be defined for tables and also table cells and headers  Border set using CSS border property table, th, td { border: 2px solid black; border-collapse: collapse; }  CSS border property - border-collapse  Border-style property specifies what kind of border to display – solid, dotted, dashed, double, inset, outset p.mix {border-style: dotted solid double;} 28Computer Network & Web Tech (SET, JU)
  • 29. Cell Padding & Border Spacing  Cell padding specifies the space between the cell content and its borders  If padding not specified, table cells to be displayed without padding  Padding set using CSS padding property th, td { padding: 15 px; }  Border spacing specifies the space between the cells  Spacing specified using CSS border-spacing property  No effect if border-collapse set table { border-spacing: 5 px; } 29Computer Network & Web Tech (SET, JU)
  • 30. Margin  CSS margin properties are used to generate space around elements  Set the size of the white space outside the border – top, bottom, left, right p { margin-top: 100px; margin-bottom: 100px; margin-right: 150px; margin-left: 80px; } p { margin: 100px 150px 100px 80px; } 4 values  top, right, bottom, left 3 values  top, right and left, bottom 2 values  top & bottom, right and left 30Computer Network & Web Tech (SET, JU)
  • 31. Margin - Inherit  CSS margin properties can be inherited from parent element div.container { border: 1px solid red; margin-left: 100px; } p.one { margin-left: inherit; } 31Computer Network & Web Tech (SET, JU)