Where should I put the CSS and Javascript code in an HTML webpage?

Viewed 115221

While designing a webpage, where should I put the following code?

<link rel=stylesheet type="text/css" href="css/layout.css">

Should I put it in the <head> or should I put it in the <body>? Please clarify the following questions:

  1. What difference does it make if I put it in <head> or anywhere else around the HTML code?
  2. What if I am having two CSS (or Javascript) files? Since I can only include one file before another one, which file will be used by the web-browser to display the webpage?
11 Answers

AS per my study in css place always inside .like:-

 <head>
  <link href="css/grid.css" rel="stylesheet" />
 </head>

and for script its depen :-

  1. If inside the script document. write present then it will be in the head tag.
  2. If script contain DEFER attribute, BECAUSE defer downloaded all in parallel

Regarding your responses, the CSS link is written akin to other head elements.

<head>
  <link href="css.script " rel="stylesheet" />
 </head>

1.Most popularly put in the head as it will augment compiling proficiency. 2.Placed in the body or later in the HTML text primarily for convenience.

Related