How to apply CSS
Rules:
§ In
This tutorial we will discuss how to apply CSS to the HTML elements.
§ We
can apply CSS to html element just by defining the CSS rules.
§ A
CSS comprises of style rules that are interpreted by the browser and then
applied to the corresponding elements in your document.
§ CSS rule is made up of two parts.
· Selector· Declaration
Selector
§ With the help of the selector, we Identifies the HTML elements at which the CSS rule is to be applied correctly .i.e. identified by the actual element name, e.g. <body>, <p>, <h1>
Declaration
§ Declaration part contains property and value.
Property
§ The properties are the style attribute put simply, all the HTML attributes are converted into CSS properties. They could be color, border etc.
Value
§ Values are assigned to properties. For example, color property can have value either red or #F1F1F1 etc.
Example: -
§ Suppose
that we want size of our text 10px then it declare as font-size: 10px. Here
font-size is properties and 10px is there value, and all this declaration is
called declaration.
Syntax:
Note:
§ With-in
Declaration Block we specify the declaration of property. The declaration is
also split into two parts, they are separated by a colon " : "
i.e. property and value is separated by colon ":"
§ However,
because a declaration can consist of several property - value pairs, and each
property - value pair within a rule must be separated by a semicolon.
Post a Comment