-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path05_id_selector.html
16 lines (13 loc) · 1.36 KB
/
05_id_selector.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<center>
<link rel="stylesheet" href="05_id_selector.css">
<h1>ID Selector</h1>
<h2>Using in external styling</h2>
</center>
<p>-->The ID selector is a fundamental feature of CSS (Cascading Style Sheets) used to target and style specific HTML elements on a webpage. It is denoted by a hash symbol (#) followed by the unique ID assigned to an element in the HTML markup. The ID selector is exceptionally specific, as IDs must be unique within a document, meaning no two elements can share the same ID.</p>
<p id="highlight">-->Uniqueness: IDs are used to uniquely identify individual elements on a page. Each ID should only be assigned to a single element.
Syntax: To select an element by its ID, you prepend the hash symbol (#) before the ID name. For example, if you have an element with the ID "myElement", the CSS selector would be #myElement.
Priority: ID selectors have a high specificity in CSS, meaning they override styles applied by class or tag selectors. This can be both an advantage and a potential pitfall when managing styles.
Applicability: While IDs can be used to apply styles directly, it's often recommended to use classes for styling and reserve IDs for targeting specific elements for JavaScript interactions or anchor links within a page.</p>
<center>
<h2 id="two">Finished</h2>
</center>