The basic idea of CSS is to redefine the display of element. For example, you can select an element p
(paragraph), and changes its property color
into green. After this, paragraph will be displayed with green foreground. Here is how the code is like:
p {color:green}
So, a CSS descriptor consists of 1) an element name, and 2) the list of properties and their assigned values in a pair of braces({}). We can add more properties separated by semicolons. For example:
p {color:green; background:yellow; line-height: 1.5em; font-size: 0.9em}
CSS code for a webpage consists of one or more lines of descriptors like the one above, each selecting one element for style customization. To insert the CSS code into HTML document, we put the code in an element named style
. For example:
<style type="text/css"> p {color:green; background:yellow; line-height: 1.5em; font-size: 0.9em} h2 {color:red; border-bottom:dashed 1px green} </style>