Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
28
rated 0 times [  35] [ 7]  / answers: 1 / hits: 118000  / 13 Years ago, fri, july 8, 2011, 12:00:00

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?


More From » html

 Answers
153

In my opinion the best practice is to place the CSS file in the header



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


and the Javascript file before the closing </body> tag



  <script type=text/javascript src=script.js></script>
</body>


Also if you have, like you said two CSS files. The browser would use both. If there were any selectors, ie. .content {} that were the same in both CSS files the browser would overwrite the similar properties of the first one with the second one's properties. If that makes sense.


[#91291] Wednesday, July 6, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mckinleyk

Total Points: 730
Total Questions: 99
Total Answers: 99

Location: South Georgia
Member since Fri, Nov 13, 2020
4 Years ago
;