Is it valid too...

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
figaro11
Forum Commoner
Posts: 64
Joined: Mon Sep 17, 2007 11:49 pm

Is it valid too...

Post by figaro11 »

Is it valid too include <script>, <link> or <style> elements in the body of you document? If so then what would be the difference in placing them in the head or body of you document?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Try it & see if it validates. The answer will probably vary depending on which DOCTYPE you're using.

For speed, Yahoo suggests putting all CSS as far up in the document as possible, and all Javascript as far down.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
figaro11
Forum Commoner
Posts: 64
Joined: Mon Sep 17, 2007 11:49 pm

Post by figaro11 »

pickle wrote:For speed, Yahoo suggests putting all CSS as far up in the document as possible, and all Javascript as far down.
Hmm. I put my css before my javascript, but only in the head. Is that what yahoo means by far down? Or do they mean at the bottom of the body?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

<link> and <style> *must* appear within the HEAD element, while it is not true for <script>.
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Post by JAB Creations »

My strict practices...

Code: Select all

<html>
<head>
<link>
<script>
</head>

<body>

</body>
</html>
I do not use the style element ever with the obvious exception for troubleshooting/forum posts.
Post Reply