Wednesday, December 12, 2012

What exactly is a web page?

What exactly is a web page? 

You start your browser, Internet Explorer for example, and type in and then what happens? It must be some kind of voodoo right? No. Actually, it's pretty simple. Boring even.


The first thing that happens is that the server which runs the web site returns some text. Here is a sample:

The text is called HTML. HTML stands for hypertext markup language.  Basically, it contains words and some special tags. The tags look like this <tag>. They usually come in pairs. The start tag is <tag> and the end tag is </tag>. Everything in between is just text or other tags. For example, the "<p>My first paragraph.</p>" defines a paragraph with the text "My first paragraph.". The "p" stands for paragraph.

Your browser takes the HTML and formats it and displays it to you. Pretty simple right?


Well, like everything else, the devil is in the details. HTML just says what is on the page but not how it should look. If you want to make your text large or use a specific font, then we need something called a cascading style sheet (CSS). CSS is another file that the server sends. This is a very simple example of a CSS file:

This particular example says make every "p" (or paragraph) element use the font "Times New Roman" and be 20 pixels tall.


So far, our page just sits there and does nothing but look nice. To do something, programmers use a language called javascript (JS). Here is a sample of some javascript:

This particular example prompts the user for a name and then updates the page to show the name.

Basically, a web page is kind of a stool that rests on these three legs. The HTML defines what is on the page. The CSS defines how it looks. And, the javascript defines how it acts. Throw in some pictures and put it on a server and you have a web site.

Most browsers will let you view the source of a web page. Right click on a page and select "View source" and you can see exactly what the programmer has written.

No comments:

Post a Comment