Prepared by: Engelbert Paul O Dela Cruz
CSS (Cascading Style Sheets) was created to separate content from presentation and ensure a consistent design across multiple webpages.
HTML was never meant for styling. The <font> tag made pages hard to manage. CSS solves that.
A CSS rule-set includes a selector and a declaration block:
selector {
property: value;
}
p { color: red; }#para1 { color: red; }.center { color: red; }h1, h2, p { color: red; }/* This is a comment */
<link rel="stylesheet" href="style.css"><style> in <head><h1 style="color: blue;">Ways to specify color:
red#ff0000rgb(255, 0, 0)rgba(255, 0, 0, 0.5)hsl(0, 100%, 50%)body {
background: #fff url("img_tree.png") no-repeat right top;
}
dotted, dashed, solid, etc.thin, medium, thickp {
border: 2px solid red;
border-radius: 5px;
}
Specify dimensions using px, %, cm, etc. max-width controls how wide an element can grow.