Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Select Topmost Elements</title> </head> <body> <script> // Prints lang attribute value of html element document.write(document.documentElement.getAttribute("lang")); // Prints: en document.write("<br>"); // Set background color of body element document.body.style.background = "yellow"; // Prints tag name of the head element's first child document.write(document.head.firstElementChild.nodeName); // Prints: meta </script> </body> </html>