SOUTH EAST ASIAN INSTITUTE OF TECHNOLOGY, INC.
National Highway, Crossing Rubber, Tupi, South Cotabato
COLLEGE OF INFORMATION AND COMMUNICATION TECHNOLOGY
___________________________________________________
IT 123 : Web Development 1
SOUTH EAST ASIAN INSTITUTE OF TECHNOLOGY, INC.
Page 1 of 8
LEARNING MODULE
FOR
IT 123: WEB DEVELOPMENT 1
_____________________________________________________
WEEK 11
COURSE OUTLINE
COURSE CODE : IT 123
TITLE : Web Development 1
TARGET POPULATION : All BS Information Technology Students
INSTRUCTOR : MS. CAROL KATE M. ESTACIO
IT 123 : Web Development 1
SOUTH EAST ASIAN INSTITUTE OF TECHNOLOGY, INC.
Page 2 of 8
Overview:
HTML stands for Hypertext Markup Language, and it is the most widely used language to write Web Pages.
Hypertext refers to the way in which Web pages (HTML documents) are linked together. Thus, the link
available on a webpage is called Hypertext.
As its name suggests, HTML is a Markup Language which means you use HTML to simply "mark-up" a text
document with tags that tell a Web browser how to structure it to display.
Originally, HTML was developed with the intent of defining the structure of documents like headings, paragraphs,
lists, and so forth to facilitate the sharing of scientific information between researchers.
Now, HTML is being widely used to format web pages with the help of different tags available in HTML language.
Content:
CSS
What CSS does
How CSS works
3 Ways to Insert CSS
CSS Syntax and Selectors
Objectives:
General Objective
Introduce you to how CSS works
Teach you how to write CSS
Introduce the different usage of selectors
Instruction to the Learner
Each chapter in this module contains a major lesson involving the basics of Web page coding and HTML editing
tool. The units are characterized by continuity, and are arranged in such a manner that the present unit is related to
the next unit. For this reason, you are advised to read this module. After each unit, there are exercises to be given.
Submission of task given will be every Monday during your scheduled class hour.
IT 123 : Web Development 1
SOUTH EAST ASIAN INSTITUTE OF TECHNOLOGY, INC.
Page 3 of 8
Styling HTML with CSS
CSS stands for Cascading Style Sheets. CSS is a stylesheet language that describes the presentation of an HTML
document. CSS describes how elements must be rendered on screen, on paper, or in other media.
Styling can be added HTML elements 3 ways:
Inline – using a style attribute in HTML elements
Internal – using a <style> element in the HTML <head> section
External – using one or more external CSS files.
CSS Syntax
A CSS rule-set consists of a selector and a declaration block:
The selector points to the HTML element you want to style. The declaration block contains one or more declarations
separated by semicolons. Each declaration includes a CSS property name and a value, separated by a colon. A CSS
declaration always ends with a semicolon, and declaration blocks are surrounded by curly braces.
The Element Selector
The element selector selects elements based on the element name.
You can select all <p> elements on a page like this (in this case, all <p> elements will be center-aligned, with a red
text color):
Example
p {
text-align: center;
color: red;
}
The ID Selector
The id selector uses the id attribute of an HTML element to select a specific element.
The id of an element should be unique within a page, so the id selector is used to select one unique element!
To select an element with a specific id, write a hash (#) character, followed by the id of the element.
The style rule below will be applied to the HTML element with id="para1":
Example
#para1 {
text-align: center;
color: red;
}
Note: An id name cannot start with a number.
The class Selector
The class selector selects elements with a specific class attribute.
To select elements with a specific class, write a period (.) character, followed by the name of the class.
In the example below, all HTML elements with class="center" will be red and center-aligned:
Example
.center {
text-align: center;
color: red;
}
IT 123 : Web Development 1
SOUTH EAST ASIAN INSTITUTE OF TECHNOLOGY, INC.
Page 4 of 8
You can also specify that only specific HTML elements should be affected by a class.
In the example below, only <p> elements with class=”center” will be center-aligned:
Example
[Link] {
text-align: center;
color: red;
}
HTML elements can also refer to more than one class.
In the example below, the <p> element will be styled according to class=”center” and to class=”large”:
Example
<p class="center large">This paragraph refers to two classes.</p>
Grouping Selectors
If you have elements with the same style definitions, like this:
h1 {
text-align: center;
color: red;
}
h2 {
text-align: center;
color: red;
}
p {
text-align: center;
color: red;
}
It will be better to group the selectors, to minimize the code. To group selectors, separate each selector with a
comma (,). In the example below we have grouped the selectors from the code above:
Example
h1, h2, p {
text-align: center;
color: red;
}
CSS Comments
Comments are used to explain the code, and may help when you edit the source code at a later date. Comments are
ignored by browsers.
A CSS comment starts with /* and ends with */. Comments can also span multiple lines:
Example
p {
color: red;
/* This is a single-line comment */
text-align: center;
}
/* This is
a multi-line
comment */
IT 123 : Web Development 1
SOUTH EAST ASIAN INSTITUTE OF TECHNOLOGY, INC.
Page 5 of 8
Three (3) Ways to Insert CSS
There are 3 ways to insert CSS
External style sheet
Internal style sheet
Inline style sheet
External Style Sheet
With an external style sheet, you can change the look of an entire website by changing just one file. Each page must
include a reference to the external style sheet file inside the <link> element. The <link> element goes inside the
<head> section:
Example
<head>
<link rel="stylesheet" type="text/css" href="[Link]">
</head>
An external style sheet can be written in any text editor. The file should not contain any html tags. The style sheet
must be saved with a .css extension.
Here is how the “[Link]” looks:
body {
background-color: lightblue;
}
h1 {
color: navy;
margin-left: 20px;
}
Note: Do not add a space between the property value and the unit (such as margin-left: 20 px;). The correct way is:
margin-left:20px;
Internal Style Sheet
An internal style sheet may be used if one single page has a unique style.
Internal styles are defined within the <style> element, inside the <head> section of an HTML page:
Example
<head>
<style>
body {
background-color: linen;
}
h1 {
color: maroon;
margin-left: 40px;
}
</style>
</head>
Inline Styles
An inline style may be used to apply a unique style for a single element. To use inline styles, add the style attribute
to the relevant element. The style attribute can contain any CSS property. The example below shows how to change
the color and the left margin of a <h1> element:
Example
<h1 style="color:blue;margin-left:30px;">This is a heading.</h1>
Note: An inline style loses many of the advantages of a style sheet (by mixing content with presentation). Use this
method sparingly.
IT 123 : Web Development 1
SOUTH EAST ASIAN INSTITUTE OF TECHNOLOGY, INC.
Page 6 of 8
Multiple Style Sheets
If some properties have been defined for the same selector (element) in different style sheets, the value from the
last read style sheet will be used.
Example
Assume that can external style sheet has the following style for the <h1> element:
h1 {
color: navy;
}
Then, assume that an internal style sheet also has the following style for the <h1> element:
h1 {
color: navy;
}
If the internal style is defined after the link to the external style sheet, the <h1> elements will be "orange":
Example
<head>
<link rel="stylesheet" type="text/css" href="[Link]">
<style>
h1 {
color: orange;
}
</style>
</head>
However, if the internal style is defined before the link to the external style sheet, the <h1> elements will be "navy":
Example
<head>
<style>
h1 {
color: orange;
}
</style>
<link rel="stylesheet" type="text/css" href="[Link]">
</head>
IT 123 : Web Development 1
SOUTH EAST ASIAN INSTITUTE OF TECHNOLOGY, INC.
Page 7 of 8
Review Questions
1. Briefly discuss the advantage of using CSS.
2. How CSS style overriding works?
3. What are the limitations of CSS?
4. What is the purpose of different measurements in CSS?
5. Can you make an Id selector particular to an element type?
6. In how many ways can a CSS be integrated as a web page?
7. What benefits and demerits do External Style Sheets have?
8. Discuss the merits and demerits of embedded Style Sheets.
9. Differentiate logical tags from physical tags.
10. What is Pseudo-elements?
Challenge
1. Create a new HTML file. (for external CSS)
2. And save it as “[Link]”
3. On your existing HTML file ([Link]) insert this CSS link inside the <head> tag “<link
rel=”stylesheet” type=”text/css” href=”[Link]”/>”
IT 123 : Web Development 1
SOUTH EAST ASIAN INSTITUTE OF TECHNOLOGY, INC.
Page 8 of 8