Fedw Unit-1 CSS
Fedw Unit-1 CSS
Prepared By
C Vikas
CSS (Cascading Style Sheets)
Unit - 1
Objectives
• This Course will help the student to comprehend and apply the concepts of
HTML,CSS and Bootstrap
• The student would be able to gain knowledge and implement the component-
based architecture
5
Basic CSS syntax
selector {
property: value;
property: value;
...
property: value;
} CSS
p {
font-family: sans-serif;
color: red;
} CSS
6
Attaching a CSS file <link>
<head>
...
<link href="filename" type="text/css" rel="stylesheet" />
...
</head> HTML
7
Embedding style sheets: <style>
<head>
<style type="text/css">
p { font-family: sans-serif; color: red; }
h2 { background-color: yellow; }
</style>
</head>
HTML
8
Inline styles: the style attribute
<p style="font-family: sans-serif; color: red;">
This is a paragraph</p>
HTML
This is a paragraph
output
9
CSS properties for colors
p {
color: red;
background-color: yellow;
}
CSS
property description
color color of the element's text
color that will appear behind the
background-color
element
10
Specifying colors
p { color: red; }
h2 { color: rgb(128, 0, 196); }
h4 { color: #FF8800; }
CSS
• color names: aqua, black, blue, fuchsia, gray, green, lime, maroon,
navy, olive, purple, red, silver, teal, white (white), yellow
• RGB codes: red, green, and blue values from 0 (none) to 255 (full)
• hex codes: RGB values in base-16 from 00 (0, none) to FF (255, full) 11
Grouping styles
p, h1, h2 {
color: green;
}
h2 {
background-color: yellow;
} CSS
12
CSS comments /*…*/
/* This is a comment.
It can span many lines in the CSS file. */
p {
color: red; background-color: aqua;
} CSS
13
CSS properties for fonts
property description
font-family which font will be used
font-size how large the letters will be drawn
font-style used to enable/disable italic style
font-weight used to enable/disable bold style
14
font-family
p {
font-family: Georgia;
}
h2 {
font-family: "Courier New";
} CSS
15
More about font-family
p {
font-family: Garamond, "Times New Roman", serif;
} CSS
16
font-size
p {
font-size: 24pt;
} CSS
17
font-size
p {
font-size: 24pt;
} CSS
18
font-weight, font-style
p {
font-weight: bold;
font-style: italic;
} CSS
19
CSS properties for text
property description
text-align alignment of text within its element
text-decoration decorations such as underlining
line-height,
gaps between the various portions
word-spacing,
of the text
letter-spacing
indents the first letter of each
text-indent
paragraph
20
text-align
blockquote { text-align: justify; }
h2 { text-align: center; }
CSS
We wants it, we needs it. Must have the precious. They stole it from us.
Sneaky little hobbitses. Wicked, tricksy, false!
output
21
text-decoration
p {
text-decoration: underline;
} CSS
22
The list-style-type property
ol { list-style-type: lower-roman; }
CSS
• Possible values:
i. none : No marker
ii. disc (default), circle, square
iii. Decimal: 1, 2, 3, etc.
iv. decimal-leading-zero: 01, 02, 03, etc.
v. lower-roman: i, ii, iii, iv, v, etc.
vi. upper-roman: I, II, III, IV, V, etc.
vii. lower-alpha: a, b, c, d, e, etc.
viii. upper-alpha: A, B, C, D, E, etc.
x. lower-greek: alpha, beta, gamma, etc.
others: hebrew, armenian, georgian, cjk-ideographic, hiragana…
23
Body styles
body {
font-size: 16px;
}
CSS
24
Cascading Style Sheets
• Properties of an element cascade together in this order:
– browser's default styles
– external style sheet files (in a <link> tag)
– internal style sheets (inside a <style> tag in the page's header)
– inline style (the style attribute of the HTML element)
25
Inheriting styles
body { font-family: sans-serif; background-color: yellow; }
p { color: red; background-color: aqua; }
a { text-decoration: underline; }
h2 { font-weight: bold; text-align: center; }
CSS
This is a heading
A styled paragraph. Previous slides are available on the website.
• A bulleted list
output
• when multiple styles apply to an element, they are inherited
• a more tightly matching rule can override a more general
inherited rule
26
Styles that conflict
p, h1, h2 { color: blue; font-style: italic; }
h2 { color: red; background-color: yellow; }
CSS
• when two styles set conflicting values for the same property,
the latter style takes precedence
27
CSS properties for backgrounds
property description
background-color color to fill background
background-image image to place in background
placement of bg image within
background-position
element
whether/how bg image should be
background-repeat
repeated
whether bg image scrolls with
background-attachment
page
shorthand to set all background
background
properties
28
background-image
body {
background-image: url("images/draft.jpg");
}
CSS
29
background-repeat
body {
background-image: url("images/draft.jpg");
background-repeat: repeat-x;
}
CSS
30
background-position
body {
background-image: url("images/draft.jpg");
background-repeat: no-repeat;
background-position: 370px 20px;
} CSS
HTML
• The link tag, placed in the HTML page's head section, can
specify an icon
– this icon will be placed in the browser title bar and
bookmark/favorite
32
References
• https://www.w3schools.com/css/default.asp
• https://developer.mozilla.org/en-US/docs/Web/CSS