Selects the element with id="tutorials" with CSS

The CSS ID selector uses the hash symbol (#) followed by an ID name to select a specific element. Since IDs must be unique within a page, this selector targets exactly one element.

Syntax

#id-name {
    property: value;
}

Example

The following example selects the element with id="tutorials" and applies a red border −

<!DOCTYPE html>
<html>
<head>
<style>
    #tutorials {
        border: 3px solid red;
        padding: 15px;
        background-color: #f9f9f9;
    }
</style>
</head>
<body>
    <h1>Tutorialspoint</h1>
    <h2>Learning</h2>
    <p id="tutorials">Tutorials on web dev, programming, database, networking, etc.</p>
    <p>Every tutorial has lessons with illustrations and figures.</p>
</body>
</html>
The paragraph with id="tutorials" displays with a red border, gray background, and 15px padding. Other paragraphs remain unchanged.

Conclusion

The ID selector (#) targets a specific element using its unique ID attribute. Remember that each ID should only be used once per HTML document.

Updated on: 2026-03-15T12:45:37+05:30

212 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements