ID and Class

Introduction

ID and Class are two of the most important concepts in CSS.
They allow you to apply styles to specific elements on a web page.

Code

<style>
#header {
  background-color: lightblue;
  color: white;
  text-align: center;
  padding: 10px;
}

.content {
  background-color: lightgray;
  padding: 10px;
}
</style>

<div id="header">
  <h1>This is a header</h1>
</div>

Output

This is a paragraph.

This is another paragraph.

Difference between ID and Class