CSS class and Id #Part 8

CSS class and Id #Part 8



What is class ??

Class is a selector that select its group. class selector selects elements with a specific class attribute. Class is denoted by (.) Dot.

Syntax

.Class name

{

//All CSS Code

}

Example

HTML Code

<p class="hello">code pocket</p>

<p>code pocket</p>

<p class="hello">code pocket</p>

<p class="hello">code pocket</p>

CSS Code

<style>

.hello

{

color:red;

font-family: cursive;

}

</style>

What is Id ??

  Id is a same as the selector class in CSS.The id selector uses the id attribute of an HTML element to select a specific element. Id is denoted by # .

Example

HTML Code

<p id="hello">code pocket</p>

<p>code pocket</p>

<p id="hello">code pocket</p>

<p id="hello">code pocket</p>

CSS Code

<style>

#hello

{

color: green;

font-family: cursive;

}

</style>


Try it Yourself...

what you think about this article ??

Post a Comment

Previous Post Next Post