(Faculty, School of Computer Science, Arellano University)

What is the web?
In a nutshell, the web is a whole bunch on

interconnected computers talking to one another.  The computers (on the web) are typically connected by phone lines, digital satellite signals, cables, and other types of data-transfer mechanisms.  A 'data-transfer mechanism' is a nerd's way of saying: a way to move information from point A to point B to point C and so on. The computers that make up the web can be connected all the time (24/7), or they can be connected only periodically.  The computers that are connected all the time are typically called a 'server'.  Servers are computers just like the one you're using now to read this article, with one major difference, they have a special software installed called 'server' software.

Web Design
The skill of designing hypertext presentations of content that is delivered to an end-user through the World Wide Web. The process of designing Web pages, Web sites, Web applications or multimedia for the Web and may utilize multiple disciplines, such as animation, authoring, graphic design, human-computer interaction, interaction design, photography, and search engine.

Technologies Involved
 Markup languages (such as HTML, XHTML and

XML)  Style sheet languages (such as CSS and XSL)  Client-side scripting (such as JavaScript and VBScript)  Server-side scripting (such as PHP and ASP)  Database technologies (such as MySQL)  Multimedia technologies (such as Flash and Silverlight)

 A style sheet language is a computer language used to describe the presentation of structured documents.
• A structured document is a document whose

sections are clearly defined and categorized (also called "well-formed"). A program presenting the document can present it in different styles because the content has been categorized.

 One modern style sheet language with widespread use is CSS (Cascading Style Sheets) , which is used to style documents written in HTML, or XHTML and other markup languages.

What is CSS???
CSS is the acronym for: ‘Cascading Style Sheets’ CSS is an extension to basic HTML that allows you to style your web pages. Style sheets let you place things exactly where you want them to be on the page, using the distance in pixels from the top and the left of the browser window.
 Styles define how to display HTML elements  Styles are normally stored in Style Sheets  External Style Sheets can save you a lot of work  External Style Sheets are stored in CSS files  Multiple style definitions will cascade into one

Advantages of CSS
CSS is an excellent addition to plain HTML.
 With plain HTML you define the colors and sizes of text and tables throughout your pages. If you want to change a certain element you will therefore have to work your way through the document and change it.

With CSS you define the colors and sizes in "styles". As you styles write your documents you refer to the styles. Thus, if you change a certain style it will change the look of your entire site. CSS offers much more detailed attributes than plain HTML for defining the look and feel of your site. Finally, CSS can be written so the user will only need to download it once - in the external style sheet document. When surfing the rest of your site the CSS will be cached on the users computer, and therefore speed up the loading time.

Things to Remember About CSS:
CSS code is simply written instructions that tells Web

browsers (like FireFox and Internet Explorer) how to display things on a page. For example:
 make text bold.  position things a page.  set the font style for a page or paragraph etc.

The sister language to CSS is HTML: code that tells

the Web browser WHAT is actually in the page.

HTML file

<html> <head> A sample HTML </head> <body> <h1>A simple HTML structure <br><br>This is header 1 </h1> <h2>This is header 2</h2> <p>This is a paragraph</p>

Using Style
 Styles are set by adding the TAG:

<STYLE ...>
 This

is placed in the <HEAD> section of your page.

CSS Syntax
The CSS syntax is made up of three parts:
1. a selector selector {property: value}
 The selector is normally the HTML element/tag you

wish to define, the property is the attribute you wish to change, and each property can take a value.

2. a property and a value:
 The property and value are separated by a colon,

and surrounded by curly braces:

body {color: black}

CSS Syntax
 Note: If the value is multiple words, put quotes around the

value: p {font-family: "sans serif"}  Note: If you wish to specify more than one property, you must separate each property with a semicolon. The example below shows how to define a center aligned paragraph, with a red text color: p {text-align:center;color:red}  Note: To make the style definitions more readable, you can describe one property on each line, like this: p { text-align: center; color: black; font-family: arial }

You can group selectors by separating each

selector with a comma. In the example below we have grouped all the header elements.
All odd header elements will be displayed in green

text color: h1,h3,h5 { color: green } All even header elements will be displayed in green text color: h2,h4,h6 { color: yellow}

The class Selector
With the class selector you can define different styles for the same type of HTML element. Say that you would like to have two types of paragraphs in your document: one right-aligned paragraph, and one centeraligned paragraph. Here is how you can do it with styles: p.right {text-align: right} {text-align: center} You have to use the class attribute in your HTML document: <p class="right"> This paragraph will be rightaligned. </p> <p class="center"> This paragraph will be center-aligned. </p>

CSS Syntax
Note: To apply more than one class per given

element, the syntax is: <p class="center bold"> This is a paragraph. </p> The paragraph above will be styled by the class "center" AND the class "bold".
You can also omit the tag name in the selector to

define a style that will be used by all HTML elements that have a certain class. In the example below, all HTML elements with class="center" will be centeraligned: .center {text-align: center}

CSS Style
In the code below both the h1 element and the p

element have class="center". This means that both elements will follow the rules in the ".center" selector: <h1 class="center"> This heading will be center-aligned </h1> <p class="center"> This paragraph will also be center-aligned. </p>

Add Styles to Elements
with Particular Attributes
You can also apply styles to HTML elements

with particular attributes. The style rule below will match all input elements that have a type attribute with a value of "text":

input[type="text"] {backgroundcolor: blue}

The ID Selector
You can also define styles for HTML elements

with the id selector. The id selector is defined as a #. The style rule below will match the element that has an id attribute with a value of "green":
#green {color: green}

The style rule below will match the p element

that has an id with a value of "para1":

p#para1 { text-align: center; color: red }

How to Insert a Style Sheet
When a browser reads a style sheet, it will

format the document according to it. There are three ways of inserting a style sheet:

1. External Style Sheet
 An external style sheet is ideal when the style is applied to

many pages. With an external style sheet, you can change the look of an entire Web site by changing one file.

2. Internal Style Sheet
 An internal style sheet should be used when a single document

has a unique style. You define internal styles in the head section by using the <style> tag.

3. Inline Styles
 An inline style loses many of the advantages of style sheets by

mixing content with presentation. Use this method sparingly, such as when a style is to be applied to a single occurrence of an element.

A. External Style Sheet-1
Each page must link to the style sheet

using the <link> tag. The <link> tag goes inside the head section:
<head> <link rel="stylesheet"

type="text/css" href="mystyle.css" />

The browser will read the style

definitions from the file mystyle.css, and format the document according to it.

A. External Style Sheet-2
An external style sheet can be written in any text editor. The file should not contain any html tags. Your style sheet should be saved with a .css extension.
 An example of a style sheet file is shown below:

hr {color: sienna} p {margin-left: 20px} body {background-image: url("images/back40.gif")}

Creating External CSS file
 External style sheets allow you to set all the rules for

the entire site in one place, giving your site a consistent look across all the pages.
• You must create a text file called mystyles.css. • Type the styles code below into the file. • Notice that this code does not have the <STYLE ...> tag in it: H2 { color:red; font-weight:900; font-family:sans-serif; }


myCSS.css- External CSS File

html File
w/ external CSS

OUTPUT of External CSS

B. Internal Style Sheet
You define internal styles in the head

section by using the <style> tag, like this:

<head> <style type="text/css"> hr {color: sienna} p {margin-left: 20px} body {background-image: url("images/ back40.gif")} </style> </head>

B. Internal Style Sheet
Note: A browser normally ignores unknown tags like

an old browser that does not support styles, will ignore the <style> tag, but the content of the <style> tag will be displayed on the page.

It is possible to prevent an old browser from displaying the content by hiding it in the HTML comment element:

<head> <style type="text/css“> <!-- hr {color: sienna} p {margin-left: 20px} body { background-image: url("images/back40.gif") } --> </style> </head>

C. Inline Styles
 To use inline styles you use the style attribute in the

relevant tag. The style attribute can contain any CSS property.  The example below shows how to change the color and the left margin of a paragraph:
<p style="color: sienna; margin-left: 20px"> This is a paragraph </p>

Single Tag CSS
CSS can be defined for single tags by simply

adding style="styledefinition:styleattribute;" to the tags. Single tag CSS is used when the style is used in a
single place on the entire site.
 Look at this example:

<h2 style="font-family:sans-serif;"> Single Tag Example</h2> It is <b style="font-size:20px;">NOT</b> me.

 NOTE: You should limit your use of single tag CSS.

Multiple Style Sheets
If some properties have been set for the same

selector in different style sheets, the values will be inherited from the more specific style sheet. For example, an external style sheet has these properties for the h3 selector:

{ color: red; text-align: left; font-size: 8pt }

CSS Layers
With CSS, it is

possible to work with layers: pieces of HTML that are placed on top of the regular page with pixel precision.

The DIV tag

That’s ALL folks…
have a happy


Sign up to vote on this title
UsefulNot useful