Static vs. Dynamic Web Pages

Web pages are simply files of computer code. This code can be divided into two major sections: display and control. The display code tells your browser what to show on the screen and where to show it. The control code can do an almost unlimited number of things, which I'll cover in a little bit. The basic difference is dynamic pages contain both display and control code, while static pages only have the display section. Here's a simple example:

Display code
HyperText Markup Language (HTML) is a code for defining how different elements (text, images, flash) are displayed on a web page. Let's say you're home page runs a sale section each month. A simplified HTML fragment for this would be:

<h2>March Sales Event</h2><br />
<img src="marchsale.jpg"><br />
<a href="marchsale.html">
Click here to save!</a>

March Sales Event

Click here to save!

It's not pretty, but it gets the idea across. The h2 tag tells the browser to display its text as a header (larger than normal body text). The img tag says show an image called marchsale.jpg under that text. The a tag displays the text 'Click here to save!' as a hyperlink to the page called marchsale.html. Once this code is added to the home page, that's what shows up every time the page loads, hence the term static.

Control code
The above example is great, until April rolls around. To change a static page, you have to go back, find the fragment and change the display code itself:

<h2>April Sales Event</h2><br />
<img src="aprilsale.jpg"><br />
<a href="aprilsale.html">
Click here to save!</a>

April Sales Event

Click here to save!

After the change, the page has to be uploaded to your hosting service. This can be very time consuming, especially if there are many changes each month. And it's why site maintenance can become very expensive. By adding control code to this fragment and making it dynamic we can change how the page displays without ever changing how the original code is written. Try it for yourself. Use the pull down menu to select an ad, then press the Change button:

March Sales Event

Click here to save!

Of course the change button would be on another page out of the public's view. But you've just changed this web page without knowing a single bit of HTML. Dynamic pages can go even further. Your computer's clock already knows what month it is. The control code can be written so the page reads the current month and automatically chooses which ad to display. Once it's set up, you never have to bother it again. The page costs more to build up front, but your site maintenance cost has gone to zero. This is just a small example of what's possible with dynamic websites

Return to Web Basics

PHP Powered CSS Valid MySQL