Cascading Style Sheets (CSS) : Mendel Rosenblum
Cascading Style Sheets (CSS) : Mendel Rosenblum
Cascading Style Sheets (CSS) : Mendel Rosenblum
(CSS)
Mendel Rosenblum
Answer: Some default from the browser (HTML tells what browser how)
Formatting information (how to display it) is in separate style sheets (.css files).
Consider can you make all the text in the app slightly bigger?
Or purple is our new company color.
body {
font-family: Tahoma, Arial, sans-serif;
Declaration color: black;
Block background: white;
margin: 8px;
}
Property Value
CS142 Lecture Notes - CSS 4
CSS
CSS HTML
Selector
h1 {
<h1>Today’s Specials</h1>
Tag name color: red;
}
.large {
<p class="large">...
Class attribute font-size: 16pt;
}
#p20 {
<p id="p20">...
Element id font-weight: bold;
}
● Coloring
● Size
● Position
● Visibility
● Many more: (e.g. p: { text-decoration: line-through; })
R G B
● Percentage intensities: rgb(80%,80%,100%)
R G B
Example: h1: { color: red; }
left margin +
right margin
1mm millimeters
2cm centimeters
0.2in inches
Relative
2em 2 times the element’s current font size
<head>
<link rel="stylesheet" type="text/css" href="myStyles.css" />
<style type="text/css">
body {
font-family: Tahoma, Arial, sans-serif;
}
</style> Page-specific styles
</head>
<body>
<div style="padding:2px; ... ">
</body>
Element-specific styles
● Composition is a problem
○ It can be really hard to figure out what rule from which stylesheet is messing things up