












Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!













What font type and size does Introduction generate?
Answer: Some default from the browser (HTML tells what browser how )
Early HTML - Override defaults with attributes
Style sheets were added to address this:
Specify style to use rather than browser default
Not have to code styling on every element
body { font-family: Tahoma, Arial, sans-serif; color: black; background: white; margin: 8px; }
Tag name
h1 { color: red; }
Today’s Specials
Class attribute
.large { font-size: 16pt; }
...
Tag and Class p.large {...}^
...
Element id
#p20 { font-weight: bold; }
...
## CSS PropertiesControl many style properties of an element:
● Coloring ● Size ● Position ● Visibility ● Many more: (e.g. p: { text-decoration: line-through; })
● Also used in animation
Must ultimately turn into red, green, and blue intensities between 0 and 255:
● Predefined names: red, blue, green, white, etc. (140 standard names)
● 8-bit hexadecimal numbers for red, green, blue: #ff
● 0-255 decimal intensities: rgb(255,255,0)
● Percentage intensities: rgb(80%,80%,100%)
Example: h1: { color: red; }
R G B
R G B
R G B
Absolute
2px pixels
1mm millimeters
2cm centimeters
0.2in inches
3pt printer point 1/72 inch
Relative
2em 2 times the element’s current font size
3rem 3 times the root element’s current font size
width - Override element defaults height
padding-top padding-right padding-bottom padding-left
margin-top margin-right margin-bottom margin-left
border-bottom-color border-bottom-style border-bottom-width border-left-color border-left-style border-left-width border-right-color border-right-style border-right-width etc. p { border: 5px solid red; }
background-image: image for element's background
background-repeat: should background image be displayed in a repeating pattern (versus once only)
font, font-family, font-size, font-weight, font-style: font information for text
text-align, vertical-align: Alignment: center, left, right
cursor - Set the cursor when over element (e.g. help)
display: none; - Element is not displayed and takes no space in layout.
display: inline; - Element is treated as an inline element.
display: block; - Element is treated as a block element.
display: flex; - Element is treated as a flex container.
display: grid; - Element is treated as a grid container.
visibility: hidden; - Element is hidden but space still allocated.
visibility: visible; - Element is normally displayed
● Inheritance ○ Some properties (e.g. font-size) are inherited from parent elements ○ Others (border, background) are not inherited.
● Multiple rule matches
○ General idea: most specific rule wins
Text1 span.test { color: green } Text2 span { color: red }
Separate style sheet (best way)
Page-specific styles
Element-specific styles
● CSS preprocessors (e.g. less) are commonly used ○ Add variable and functions to help in maintaining large collections of style sheets ○ Apply scoping using the naming conventions
● Composition is a problem ○ It can be really hard to figure out what rule from which stylesheet is messing things up