CSS Selectors ID selectors

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

ID selectors select DOM elements with the targeted ID. To select an element by a specific ID in CSS, the # prefix is used.

For example, the following HTML div element…

<div id="exampleID">
    <p>Example</p>
</div>

…can be selected by #exampleID in CSS as shown below:

#exampleID {
    width: 20px;
}

Note: The HTML specs do not allow multiple elements with the same ID



Got any CSS Question?