Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to apply CSS to any element for html page ?

Here i explain, what is CSS and how to use ?


What is CSS ?
CSS stands for Cascading Style Sheet. CSS is used to provide layout to html pages easy and efficiently.We can apply same CSS style to individual item or single page or multiple pages.
External CSS stylesheet can be apply to multiple pages.This is very helpful ,when you want same style for your website.

how to apply CSS?
we have syntax to apply CSS.
Syntax:element where have to apply{property:value;}

example: img { width: 200px; height: 200px;}

For apply CSS to any Html Element, we have to define CSS selector for particular HTML element.For these we have these selector.

1. Element selector 
This selector apply CSS to that HTML element that is define by Element.

Example: If we want to apply text color to paragraph using CSS.Follow these instructios:-

    p{color:red;}


2. Id selector 
This selector apply CSS to HTML element which is define with id attribute.

Example:If we want to apply text color to paragraph using CSS which is define by Id. Follow these instructios:-

    #par{color:red;}


3. Class selector 
This selector apply CSS to HTML element which is define with class attribute.

Example:If we want to apply text color to paragraph using CSS which is define by class. Follow these instructios:-

    .par{color:red;}


If you want to apply same CSS for different HTML elements,you can do this by following:-
Example:-

    h1,p{color:red;}


This post first appeared on The Code Developer, please read the originial post: here

Share the post

How to apply CSS to any element for html page ?

×

Subscribe to The Code Developer

Get updates delivered right to your inbox!

Thank you for your subscription

×