As we discussed before a website is a series of HTML pages. This is a little simplification, there are several components that make up your HTML pages.
- First you Hyper Text Mark Up Language. HTML contains tags. A tag is made up of a word or series of words inside <>, this tag is the closed with a tag that contains the same work preceded by a / (example <h1>Headline</h1>. The text between the opening and closing tag is effected by the tags. In the example the h1 tag is the top most “headline” tag, so this means the main headline of the page is Headline. These tags can also simply mark the text for some particular purpose.
- CSS (Cascading Style Sheets) – HTML contains attributes that allow you to style the HTML element, but this can be messy. If you style in HTML you need to maintain this style every time you change the HTML. CSS allows you to separate the content from the style. Basically with CSS you can associate a style with an HTML tag. You can tell the web browser to apply a particular style to all h1 elements. In practice most of the time you use the ID or Class attribute of the tag to apply the style. A normal example is that you would assign a font style (like verdana), size (like 12 px), color (like dark grey) and background color (say white). Then you will assign that your H1 tag should be larger (like 20 px). The h1 text will inherit all the color and style attributes and change the size to 20 px.
- Java Script – Java is a programming a common programming language. All modern web browsers have the capability to run a specific part of this language called Java Script. This language allows you to make changes to your HTML programmatically. Java Script allow you to add interactivity to you static HTML page. Say you want something to happen when you click on something on the HTML page. All HTML can do is ask the server for a new page, which can take several seconds. If you make this same effect take place in java script in the browser you can make it happen quickly to get the interactive feel.
There is more to most websites that simple text, They will use CSS to maintain a consistent style and Java Script to make the page more interactive to the user.
One other thing to keep in mind with webpages is that web servers are stateless. What this means is that every time you request a web page it is like you are asking for it the first time, the server does not maintain any state of any previous pages loaded. A well planned application will change things based on what the user has done in the past. To get this interaction web servers can request and store information with the web browser in two main manners.
- The web browser maintains a session variable. Part of the interaction of between the web server and browser includes communicating the contents of the session variable. This variable is destroyed when the web browser is closed. When you visit a website the session is considered open until you close you web browser.
- There is also a permanent storage the web browser maintains called Cookies. Many times you go to a site and place things into you shopping cart. Then you close your browser and go back to the site 2 days later and your items are still in the shopping cart. Your shopping cart is stored in the cookies.
Cookies and sessions are sensitive areas. Many are concerned about something being stored about you with out your knowledge. One of the common usages for Cookies is to store your userid on a private site (one that requires you to login). Then when you visit the site you will be automatically logged in. If your are only concerned with privacy, that is keeping the information private and not keeping information secrete, such as a banking site, this is an accepted practice. The cookie is kept in the browser, you are not “logged in” to the server but the cookie allows the server to log you in when you return. This is kept in the browser so it will not work in a different browser on your machine or a different machine. Governments are starting to be concerned with privacy of cookies and sessions. Currently the EU requires you to get permission to store any information before hand. This can be an issue because many time the programmer expects this type of storage to operate properly.