Javascript – What’s the difference between HTML and tags

htmljavascript

What's the difference between HEAD tags and BODY tags?

most HTML books only 'briefly' mentions <head> and <body> tags…but they just go away really fast.

Do they affect how browsers render web pages?

Also, do they affect the order in which javascripts are run?

(I mean, if I have a javascript inside a <head> tag, would it run BEFORE another javascript inside <body> tag? Even when <body> came BEFORE <head>?)

This is too confusing–I haven't ever used a head/body tags, but i never had any trouble with it.
But while reading Jquery tutorial, I saw people recommending putting some codes inside <head> and the others inside <body> tags.

Thank you!!!

Best Answer

  • Things in the head tag are things that shouldn't be rendered: information about the page and how to process it.
  • Things in the body tag are the things that should be displayed: the actual content.
  • Javascript in the body is executed as it is read and as the page is rendered.
  • Javascript in the head is interpreted before anything is rendered.
Related Topic