Is it correct to say that the <body> element is nested within the <html> element?



Is it correct to say that the <body> element is nested within the <html> element?


That is correct! The <html> tag is the root element of every page and it should always have <head> and <body> child elements. The <head> and <body> elements are siblings to each other and children to the <html> parent.

FAQ: Learn HTML Elements - Intro to HTML - HTML Structure

To add to this, there is one other element permitted to be a direct child of <html></html> which is more commonly found in either the <head></head> after CSS links, or in the <body></body> element at the very bottom…


It may appear after the </body> tag, and is valid, though not typical.


<!DOCTYPE html>
<html lang="en">
  <script src=""></script>
    // JS code


Are elements also functions? or do they fall under both function and variable?


No, they are HTMLElement objects that make up the nodes from which the DOM is constructed. Are not variables, either. Both functions and variables are properties of the scripting language, usually JavaScript, but it could also be Python, Ruby, etc.


i am so confused :(:cry:


so <head>, <body> and <script> are all children of <html>, correct?


Yes and no. The convention is to write the script tag inside either/or both head and body. While browsers might accept a script outside of the head/body elements, the specification recommends,

Permitted parents Any element that accepts metadata content, or any element that accepts phrasing content.

The HTML root element can only have two children… HEAD and BODY.