Monday, September 13, 2010

Attaching external documents

A web page—as in the (X)HTML document—is primarily designed to contain content that
is structured in markup. Presentation should be dealt with via external CSS documents,
and behavior via external scripting documents. Although it is possible to work with the
likes of JavaScript and CSS within an HTML document, this goes against the modular
nature of good web design. It’s far easier to create, edit, and maintain a site if you work
with separate files for each technology. (The exception is if your “site” is only a single page,
therefore making it sensible to include everything in a single document.)
As already mentioned, XHTML documents are text files that are saved with the suffix .html
(or .htm). CSS and JavaScript files are also text documents, and their file suffixes are .css
and .js, respectively. When you start a project, having already set the relevant DOCTYPE
and added meta tags, it’s a good idea to create blank CSS and JavaScript files and to attach
them to your web page, so you can then work on any element as you wish.

No comments:

Post a Comment