ID Selector
An HTML id
is a unique selector
used to identify a specific HTML element.
The id is primarily used to assign a unique id
to a specific element, allowing it to be selected and manipulated with CSS or JavaScript.
Due to this uniqueness, multiple HTML elements cannot share the same id.
The id
selector is defined with a #
as shown below.
Example of Using HTML id
<style> #intro { font-size: 24px; font-weight: bold; color: green; } </style> <p id="intro">Welcome</p>
The code above selects an HTML element with the id intro
using #intro
, applying styles that are only applicable to this HTML element.
Note that ids are case-sensitive. For example, Intro
and intro
are considered different ids.
However, ids are conventionally written in lowercase
.
Mission
0 / 1
What is the most appropriate answer to fill in the blank?
An HTML id is a used to uniquely identify a specific HTML element.
class
identifier
attribute
tag
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help