by
Roshan Thapa , Database and Communication Manager , Finaccess Private Limited
Class is a name given to CSS definition that applies to all the HTML elements that use the specified class for rendering.
A class selector is named by having a DOT (.) at the beginning such as .ClassName and the CSS defined is applied to all the HTML elements that use this class.
For example, you can have a CSS class as follows:
.myClass
{
background-color:blue;
}
and if you specify an HTML element with the above specified class such as , then, all the elements within this DIV will have a blue background. While using a class definition in HTML, you MUST omit the dot(.) i.e. you need to specify class name in HTML element as "myClass" not ".myClass"
very simple select any element of html and assign to it my defined class name in css
definde in css :
.myparageraph
{
font-family: verdana;
}
and using it in html element
The .class selector styles all elements with the specified class
for example
Style all elements with class="home":
p.home
{
background:blue;
}
My name is Kaombwe.
I live in Tanzania.
My name is Kaombwe.
I also live in Tanzania.
by
adil khan , In Top 5 Employees , Harbin Institute of Technology, Harbin, China
The .class selector styles all elements with the specified class
for example
Style all elements with class="hometown":
p.hometown
{
background:yellow;
}
My name is Donald.
I live in Ducksburg.
My name is Dolly.
I also live in Ducksburg.