Section 3 CSS (part1)
Section 3 CSS (part1)
Lab 3: CSS
Course Outline
1. Hypertext Markup Language (HTML)
2. Cascading Style Sheets (CSS)
3. Java Script (JS)
4. Programming in PHP
5. MYSQL
6. Laravel framework
CSS (Cascading Style Sheets)
Part 1
CSS Syntax
selector{
CSS is the language we use to style an HTML document.
4
CSS Syntax
<HTML>
<HEAD>
<TITLE> CSS </TITLE>
<style>
h1 {
color: blue;
font-size: 12px;
}
</style>
</HEAD>
<BODY>
<h1> Hello World! </h1>
</BODY>
</HTML>
5
CSS Selectors
CSS selectors are used to "find" (or select) the HTML elements you want to style.
8
Three Ways to Insert CSS دا اﻟﻲ ﻣﺗﻌود ﻋﻠﯾﮫ
External CSS external internal inline
With an external style sheet, you can change the look of an entire website by changing one file!
Internal CSS
An internal style sheet may be used if one single HTML page has a unique style.
<head>
<style>
h1 {
color: maroon;
} 9
</style>
</head>
Three Ways to Insert CSS
Inline style
add the style attribute to the relevant element. The style attribute can contain any CSS
property.
<p style="text-align: center;"></p>
attribute ﻋﻠﻲ ﺷﻛلstyle اﺧﻠﻲ ال
10
CSS Backgrounds
background-color
h1 {
background-color: green;
}
background-image
body {
background-image: url("bgdesert.jpg");
}
background-repeat
body {
background-image: url("bgdesert.jpg");
11
background-repeat: repeat-x;
}
CSS Backgrounds
background-position
h1 {
background-image: url("img_tree.png");
background-repeat: no-repeat;
background-position: right top;
}
background-size
div {
background-image: url("img_tree.png");
background-repeat: no-repeat;
background-size: 100% 100%;
} 12
CSS Borders
border-style
h1 {
border-style: dashed;
}
background-width
div {
border-width: 5px;
} دول اﺳﺎﺳﯾﯾن ﻻزم ﯾﺗوﺟدوا3ال
background-color
div {
border-color: red;
13
}
CSS Borders
border-radius
h1 {
border-radius: 5px;
}
div {
width: 300px;
margin: auto;
} 15
CSS Margins
used to create space around elements, outside of any defined borders.
h1 {
margin-top: 100px;
}
div {
width: 300px;
margin: auto;
} 16
CSS Padding PADDING --> INSIDE ﻋﻠﻲ ﻋﻛس اﻟﻣﺎﺟﯾﻧﺞ
used to generate space around an element's content, inside of any defined
borders.
h1 {
padding-top: 100px;
}
17
CSS Text
Color
h1 {
color: green;
}
Text Alignment
h1 {
text-align: center;
}
Text Direction
body {
direction: rtl;
18
}
CSS Text دﯾﻛورﯾﺷن ﻣش داﯾﯾﻛﺷن
Text Decoration دﯾﻛو ﯾﻌﻧﻲ اﻟﺧط اﻟﻲ ﺣوﻟﯾﮫ و ﻟوﻧﮫ و رﻓﻌﮫ و ﺳﺗﺎﯾﻠﮫ
h1 {
text-decoration-line: overline;
text-decoration-color: red;
text-decoration-style: solid;
text-decoration-thickness: 5px;
}
19
CSS Fonts
Font Family
p { font-family: "Times New Roman";}
Font Style
p { font-style: italic; }
Font Size
p { font-size: 14px; }
Text Transformation
P { text-transform: lowercase/ uppercase/ capitalize;}
Text Indentation
p { text-indent: 50px; } 20
Practice
21