A CSS
comprises of style rules that are interpreted by the browser and then applied
to the corresponding elements in your document. A style rule is made of three
parts −
· Selector − A selector is an HTML tag at
which a style will be applied. This could be any tag like <h1> or
<table> etc.
· Property - A property is a type of
attribute of HTML tag. Put simply, all the HTML attributes are converted into
CSS properties. They could becolor, border etc.
· Value - Values are assigned to
properties. For example, color property can have value either red or #F1F1F1
etc.
You can put
CSS Style Rule Syntax as follows −
selector {
property: value }
Syntax
Example: You
can define a table border as follows −
table{ border
:1px solid #C00; }
Here table is
a selector and border is a property and given value 1px solid #C00is the value
of that property.
You can define
selectors in various simple ways based on your comfort. Let me put these
selectors one by one.
The Type
Selectors
This is the
same selector we have seen above. Again, one more example to give a color to
all level 1 headings:
h1 {
color: #36CFFF;
}
The Universal
Selectors
Rather than
selecting elements of a specific type, the universal selector quite simply
matches the name of any element type −
* {
color: #000000;
}
This rule
renders the content of every element in our document in black.
0 Comments