JavaScript QuerySelector - par id

<p id="id1">1st paragraph with id = id1</p>
<p id="id1">2nd paragraph with id = id1 (incorrect use)</p>
<button onclick="getElement()">Get element</button>

<script>
  function getElement() {
    // selecting element by its id
    let element = document.querySelector("#id1");

    element.style.background = "lightgreen";
  }
</script>
Clumsy Caiman