---
title: "Class, ID and Tag selector in HTML"  
description: "Class, ID and Tag selector in HTML"  
author: "Anonymous User"  
published: 2021-07-20  
updated: 2021-07-20  
canonical: https://www.mindstick.com/forum/156537/class-id-and-tag-selector-in-html  
category: "html"  
tags: ["html", "html5"]  
reading_time: 2 minutes  

---

# Class, ID and Tag selector in HTML

How to use [Class](https://www.mindstick.com/blog/165/generic-class-in-c-sharp), ID and tag [selector](https://www.mindstick.com/interview/23419/action-selector-in-mvc) in [HTML](https://www.mindstick.com/articles/1530/design-a-simple-stylish-calculator-using-html-css-and-javascript) [web page](https://www.mindstick.com/forum/718/sql-server-report-alignment-to-center-of-web-page)?

## Replies

### Reply by Anonymous User

## CSS Selectors

CSS selectors are used to 'find' (or select) the HTML elements you want to style.

We can divide CSS selectors into five categories:

- Simple selectors (select elements based on name, id, class)
- Combinator selectors (select elements based on a specific relationship between them)
- Pseudo-class selectors (select elements based on a certain state)
- Pseudo-elements selectors (select and style a part of an element)
- Attribute selectors (select elements based on an attribute or attribute value)

Let's take an example of id, class and tag selector :

```
<!DOCTYPE html>
<html lang='en' xmlns='http://www.w3.org/1999/xhtml'>
<head>
    <meta charset='utf-8' />
    <title>Selector</title>
    <style>
        h1{
            text-decoration:underline;
        }
        .text-center{
            text-align:center;
        }
        #para{
            color:white;
            background:black;
        }
    </style>
</head>
<body>
    <h1>Tag Selector</h1>
    <p id='para'>ID selector</p>
    <p class='text-center'>Class selector</p>
</body>
</html>
```

Hope this information will be helpful for you.

Happy Coding!


---

Original Source: https://www.mindstick.com/forum/156537/class-id-and-tag-selector-in-html

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
