What's the point?

windows

Guest
What's the point in having a head and a body? Why not just have nothing but programing? It's not an essay. I'm using Dreamweaver and it puts the Javascript wherever it wants it, usually in the head part and now I'm hearing that's not good. <br />
ALso what's the point in creating external .js files?<br />
Isn't that really just additional internal linking which in turn slows things down?<br />
Your thoughts are welcome.<br />
Shan.<!--content-->Hmm there's no programming in HTML...<br />
Today we have very tolerant browsers, which will try to make the best out of any code they read.. However, there are very strict rules after which a page should be made. The HTML 4.01 Specification (<!-- m --><a class="postlink" href="http://www.w3.org/TR/html401/">http://www.w3.org/TR/html401/</a><!-- m -->) might be interesting for you to read, it will surely give you more insight into what HTML actually is. The idea behind HEAD and BODY is basically a better structure. In the BODY, should the content and layout of the page be, while as all the information about the page should be in the HEAD.<br />
It is recommended that you put the SCRIPT in the BODY, no matter what Dreamweaver does.<br />
The major point of external files is quite simple.. Say you have a hundred pages that all need the same JS code. If you suddenly find a bug in that code, you wouldn't want to change it in a hundred pages, right? It's always better to never duplicate code, in case you want to change a part of it. I really doubt that the include slows things down, you have to Download <!--more--> the same amount of data anyway. Another reason for including the code, can be that you just have a lot of code, and working with an HTML file of 2000 lines, isn't that much fun, unless you like to roll that scolling wheel on your brand new mouse a lot.<br />
<br />
cheers :)<!--content-->You don't embed the binary data for an image or a sound inside the HTML file do you? You use external files.<br />
<br />
The same ought to apply to javascript code and to stylesheets. This allows for code re-use across the site, ease of maintainance, and smaller, easier to deal with, HTML files.<br />
<br />
External is the way to go.<br />
<br />
If the js code has to write something to the page, then the external javascript file should be called at the point that the content is to appear. If the file does not write to the page then it can go in the <head> section.<br />
<br />
All external CSS stylesheets must be called from the <head> section.<!--content-->"It is recommended that you put the SCRIPT in the BODY, no matter what Dreamweaver does."<br />
<br />
My apologies, I did not mean BODY, but HEAD. Scripts go in the HEAD, with the exception that giz mentioned.<!--content-->Now I can justify the hard time I'm having getting the external files to link and work.<br />
As for Dreamweaver, I'll just let it do it's thing. It made me curious though when I saw a very large JS timeline inserted into the head.<br />
Thanks for your replies.<br />
Shan.:D<!--content-->I have never found this advice to fail:<br />
<br />
<br />
<br />
Javascript is best done with external .js files, called using:<br />
<script type="text/javascript" language="javascript" src=http://www.htmlforums.com/archive/index.php/"/path/file.js"></script><br />
<br />
<br />
<br />
In CSS you must have units with all of your numbers, so one of either px, pt, em, %, or # is always required.<br />
<br />
<br />
You should export the CSS to an external file and call it with a one line instruction in the <head> section:<br />
<link type="text/css" rel="stylesheet" src=http://www.htmlforums.com/archive/index.php/"/path/file.css"><!--content-->
 
Back
Top