Techcss
Untitled Document

CSS Class & Ids

The CSS allow to define 'class' or 'id' in the CSS code which can be decleared in HTML element to stylize.


CSS Id

Ids always start with a '#' sign while defining in style sheet.
This is a bad approach to start id name by a number.

Example:

<!DOCTYPE html>
<html>
<head>
<style>
#exmp{
padding:10px;
background-color:#669933;
color:#003300;
}
</style>
</head>

<body>

<h2>The example of id</h2>
<p id="exmp">This is paragraph one </p>
<p>This is paragraph two</p>
</body>
</html>

Output:

The example of id

This is paragraph one

This is paragraph two


CSS Class

Classes always start with a '.' sign while defining in style sheet.

Example:
<!DOCTYPE html>
  <html>
  <head>
  <style>
  .exmp{
  padding:10px;
  background-color:#669933;
  color:#003300;
  }
  </style>
  </head>
  <body>
  <h2>The example of class</h2>
  <p class="exmp">This is paragraph one </p>
  <p>This is paragraph two</p>
  </body>
  </html>
Output:

The example of class

This is paragraph one

This is paragraph two