Lec 3-CSS_1.5m
Lec 3-CSS_1.5m
Content
Basic CSS
Advanced CSS
2
Basic CSS
3
Content vs. Presentation
4
Content vs. Presentation (cont.)
5
Inline Style Sheets
• Using the style attribute, you can specify presentation style for a single
HTML element
• within tag, list sequence of property:value pairs separated by semi-colons
<html>
<!–- CS443 page17.html 17.10.14 -->
font-family:Courier,monospace
font-style:italic <head>
<title>Inline Style Sheets</title>
font-weight:bold </head>
font-size:12pt font-size:large font-size:larger
<body>
<p style="font-family:Arial,sans-serif;
color:red color:#000080 text-align:right">This is a
right-justified paragraph in a sans serif
background-color:white font (preferably Arial), with some
<span style="color:green">green text</span>.
</p>
text-decoration:underline
<p>And <a style="color:red;
text-decoration:none text-decoration:none;
text-align:left text-align:center font-size:larger;"
href="page01.html">here</a>
text-align:right text-align:justify is a formatted link.
</p>
vertical-align:top vertical-align:middle </body>
vertical-align:bottom </html>
6
Inline Style Sheets (cont.)
margin-left:0.1in margin-right:5%
margin:3em
padding-top:0.1in padding-bottom:5% <html>
<!–- CS443 page18.html 17.09.09 -->
padding:3em
<head>
<title>Inline Style Sheets</title>
border-width:thin border-width:thick </head>
border-width:5 <body>
border-color:red <p>Here is an image
<img src="VictoriaBldg.jpeg"
border-style:dashed border-style:dotted alt="image of Victoria Building"
style="margin-left:0.3in;
border-style:double border-style:none margin-right:0.3in;
vertical-align:middle;
border-style:double;
whitespace:pre border-color:blue" />
embedded in text.
</p>
list-style-type:square <ol style="list-style-type:upper-alpha">
list-style-type:decimal <li> one thing</li>
<li> or another</li>
list-style-type:lower-alpha <ul style="list-style-type:square;
list-style-type:upper-roman whitespace:pre">
<li> with this</li>
<li> or that</li>
</ul>
</ol>
</body>
</html>
view page
7
Inline Style Sheets (cont.)
<html>
<!–- CS443 page19.html 17.10.14 -->
view page
8
Document Style Sheets
9
Document Style Sheets
paragraphs
</head>
<body>
10
Document Style Sheets (cont.)
<html>
<!–- CS443 page21.html 17.10.14 -->
tables
table {font-family:Arial,sans-serif}
caption {color:red;
font-style:italic;
text-decoration:underline}
th {background-color:red}
view page
11
External Style Sheets
12
Modularity & Style Sheets
<html>
options in an external style sheet. <!–- CS443 page26.html 17.10.14 -->
<head>
structure/content tags
the first line indented, but subsequent lines
will be flush.</p>
</body>
</html>
view page
13
Advaned CSS
14
Rounded Corners
#rcorners2 {
border-radius: 25px;
border: 2px solid #73AD21;
padding: 20px;
width: 200px;
height: 150px;
}
15
Rounded Corners
#rcorners1 {
border-radius: 25px;
background: #73AD21;
padding: 20px;
width: 200px;
height: 150px;
}
16
Universal, Child, and Adjacent Selectors
* {
margin: 0;
padding: 0;
Example: set the margin and padding
} on everything in a page to zero and
#contact * {
display: block; everything within an element with the
} ID “contact” to be displayed as a block
17
Universal, Child, and Adjacent Selectors
Example: set the border for all <li> child of element has
id=“genus_examples”
18
Universal, Child, and Adjacent Selectors
<h1>Clouded leopards</h1>
<p>Clouded leopards are cats that belong
to the genus Neofelis.</p>
<p>There are two extant species: Neofelis
nebulosa and Neofelis diardi.</p>
h1 + p { font-weight: bold }
Only the first paragraph, that following the heading, will be made bold.
19
Advanced Colors
20
CSS Transitions
21
Backgrounds: Multiples, Size, and Origin
22
Transformations
23
Position
24
Exercises
• https://www.w3schools.com/css/default.asp
• https://www.w3schools.com/css/css_exercises
.asp
• https://www.freecodecamp.org/learn/2022/re
sponsive-web-design/
• Build your personal page
25
TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG
School of Information and Communication Technology
26