What's the difference between HTML <head> and <body> tags?

后端 未结 8 934
庸人自扰
庸人自扰 2021-01-31 09:19

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

most HTML books only \'briefly\' mentions and tags...but they

8条回答
  •  臣服心动
    2021-01-31 09:57

    In my little knowledge:

    JavaScript in the head section is usually meant to preload certain files (usually procedures or functions as the case may be). For example, a website that utilizes the Time() or Date() function would require that the .js file that contains those functions be called before the website is fully loaded allowing the instance to be available (preloaded) before imminent usage. Same also applies to other custom functions.

    JavaScript in the body section is primarily for adding extra functionality to a website. An example is in the case of a custom .js file where a function is to check for correctness of words in an input string or matching all characters entered in an input string to be of a certain length.

    The downside of using either of these two conventions is in calling a custom .js file (meant for website functionality) from the head section. The implication is that the JS file would've already exhausted it's functionality before the website contents are fully loaded.

提交回复
热议问题