<a href="#section2">Go to Section 2</a>

<!-- Click the link above to scroll down to this element -->
<div id="section2">
  <h2>Section 2 Content</h2>
</div>
#css-selector { /* Select by id attribute value: #id-value selector */
    background-color: yellowgreen;
}
<p>Paragraph element.</p>
<p id="css-selector">Paragraph element.</p>
<p>Paragraph element.</p>
<p>Paragraph element.</p>
Rendered Output
<p id="txt">Welcome.</p>
<button type="button" id="btn">Click to change the text</button>

<script>
    const txt = document.getElementById("txt"); // Identify id="txt"
    const btn = document.getElementById("btn"); // Identify id="btn"

    btn.addEventListener("click", () => {
        txt.innerHTML = "Nice to meet you.";
    });
</script>
Rendered Output Try clicking the button!
Fragment in a URL (also called a hash URL)
<a href="#section2">Go to Section 2</a>

<!-- Click the link above to scroll down to this element -->
<div id="section2">
  <h2>Section 2 Content</h2>
</div>
<!--
    The id value "user-checking" of the target form control element
    is assigned to the label's for attribute.
-->
<label for="user-checking">Click me.</label>
<input type="checkbox" id="user-checking">
Rendered Output Clicking the text of the <label> element ("Click me.") moves focus to the associated checkbox.
<p>Paragraph element.</p>
<p id="css-selector">Paragraph element.</p>
<p id="css-selector">Paragraph element.</p> <!-- Duplicate -->
<p>Paragraph element.</p>