Lập trình web tĩnh Html dành cho người mới bắt đầu học lập trình web Mình khuyên các bạn nên học đầy đủ từ bài số 1 trở điVà kết hợp với video khi sử dụng slide nhưng do video mình chưa có thời gia up lên khi nào có mình sẽ cho link lên mục này
Trang 1Session 3
Module 5: Introduction to CSS
Module 6: CSS Color and Layout Properties
Trang 2Session 3 – Objectives (1)
Trang 3Session 3 – Objectives (2)
Trang 4What is CSS?
control styles
presentation of an HTML document as it will be presented on screen, or even in print
appearance of elements on a page and create
Trang 5is still under development
Trang 6CSS Syntax
one or more declarations
Trang 7CSS Comments
may help you when you edit the source code at
Trang 8elements the corresponding rule applies to
o HTML element selectors
o Class selectors
o ID selectors
Trang 9HTML Element Selectors
elements
brackets So, the HTML <p> tag become p
Trang 10HTML Element Selectors Demo
Trang 11ID Selectors
single, unique element
element, and is defined with a "#"
element with id="elementid":
o CSS:
#elementid {color: red; text-align: center;}
o HTML:
<h1 id="elementid">ID selector</h1>
Trang 13Class Selectors (1)
group of elements Unlike the id selector, the class selector is most often used on several elements
HTML elements with the same class
attribute, and is defined with a "."(dot)
Trang 14Class Selectors (2)
class="center" will be center-aligned:
Trang 15Class Selectors (3)
elements should be affected by a class
class="center" will be center-aligned:
Trang 16Class Selectors Demo
Trang 17Ways to Insert CSS (1)
<p style="color: red;">This is a paragraph.</p>
Trang 18Ways to Insert CSS (2)
o Use link element
Trang 19Inheritance in CSS
Trang 20CSS Unit
For width, height, margin, padding, border property:
Trang 21 For color, background property:
CSS Color
Trang 22 Browser support:
o The color property is used to set the color of the text.
body {color: blue;}
Trang 25Text Properties Demo
<p>Link to: <a href="http://aptech.ac.vn">FPT Aptech</a></p>
<p class="uppercase">This is some text.</p>
<p class="capitalize">This is some text.</p>
Output
Trang 26Font Properties (1)
boldness, size, and the style of a text
Trang 27Font Properties (2)
Trang 29o Font-weight property sets how thick or thin characters
in text should be displayed
• bold { font-weight: bold; }
• p { font-weight: 900; }
Trang 30Font Properties Demo
<p class="serif">This is a paragraph, shown in the
Times New Roman font.</p>
<p class="sansserif">This is a paragraph, shown in
the Arial font.</p>
Output
Trang 31Link Properties (1)
color, font-family, background, etc.)
o a:link - a normal, unvisited link
o a:visited - a link the user has visited
o a:hover - a link when the user mouses over it
o a:active - a link the moment it is clicked
Trang 32Link Properties (2)
o a:link {color: #FF0000;} /* unvisited link */
o a:visited {color: #00FF00;} /* visited link */
o a:hover {color: #FF00FF;} /* mouse over link */
o a:active {color: #0000FF;} /* selected link */
o a:link {background-color: #B2FF99;}
o a:visited {background-color: #FFFF85;}
Trang 33Color Properties
o The color property is used to set the color of the text.
body {color: blue;}
h1 {color: #00ff00;}
h2 {color: rgb(255,0,0);}
Trang 34Background Properties
background color of an element
o body {background-color: #b0c4de;}
o h1 {background-color: #6495ed;}
o div {background-color: #b0c4de;}
image to use as the background of an element
body
{
Trang 35CSS Box Model (1)
In CSS, the term "box model" is used when talking about design and layout
Trang 36CSS Box Model (2)
margin does not have a background color, it is completely transparent
and content The border is affected by the background color of the box
padding is affected by the background color of
Trang 37CSS Box Model (3)
content
Trang 38CSS Box Model (4)
Trang 41CSS Border Properties (2)
Trang 42Margin Properties (1)
elements
for different sides:
o margin-top: 100px;
o margin-bottom: 100px;
o margin-right: 50px;
o margin-left: 50px;
Trang 44Padding Properties (1)
between the element border and the element
content
for different sides:
o padding-top: 25px;
o padding-bottom: 25px;
o padding-right: 50px;
Trang 46Box Model Demo
Trang 47Table Properties (1)
Trang 48Table Properties (2)
<style type="text/css">
table {border-collapse: collapse;}
table,th,td {border: 1px solid black;}
</style>
<style type="text/css">
Trang 49Session 3 – Summary (1)
control styles
one or more declarations
elements the corresponding rule applies to
o HTML element selectors
o Class selectors
o ID selectors