<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>JavaScript</title>
  <script>
    function initiate() {
      const mainelement = document.getElementById("mainsection");
      const list = mainelement.getElementsByTagName("p");
      const element = list[0];
      alert("The id is: " + element.id);
    }
  </script>
</head>
<body onload="initiate()">
  <section id="mainsection">
    <h1>Website</h1>
    <p id="subtitle">The best website ever!</p>
  </section>
</body>
</html>