Professional Documents
Culture Documents
Lesson 1
The Web Page
Untangled
The Web Page
Untangled
<html>
<head>
<title>Hello!</title>
</head>
<body>
This is my first time to
make a Web page.
</body>
</html>
Web Tools
<tag> is the opening tag; content is the plain text or image; and </tag> is the closing tag
Note:
All tags need to be in lowercase because XHTML is a case-sensitive application
(it interprets <TAG /> and <tag /> differently).
property: value
where property is the feature of, for example, a paragraph, which
you want to style; and value the style itself, for example, a
measurement for the height of one line in a paragraph. An example
of CSS application inside HTML tags is this:
Writing out
The Web Page
Writing out The
Web Page
Heading
Paragraph
Lists
Preformatted Text
Horizontal Rule
Heading
<html>
<head>
<title>Go Web!</title>
</head>
<body>
<h1>Go Web!</h1>
<h2>Go Web!</h2>
<h3>Go Web!</h3>
<h4>Go Web!</h4>
<h5>Go Web!</h5>
<h6>Go Web!</h6>
</body>
</html>
Paragraph
<head>
<title>Paragraph</title>
</head>
<body>
<p>It’s so easy to make
Web pages. I’ve learned
all about headings and
paragraphs in less than
half an hour! Can you
believe that?</p>
</body>
</html>
<html>
<head>
<title>Playing with Tags</title>
</head>
<body>
<p>My favorite band is blink 182. I
bought all the CDs of blink 182
because I like their music so
much.</p>
<p>Here is my office address:<br />
Unit 11 Temporal Place<br />
Surely Intelligent Lane<br />
Busy City Philippines</p>
<p>Hmmm... this is another
paragraph. Did you notice the line
break after the previous paragraph
and before this one?</p>
<br /><br />
<p>Let’s take a break. No, wait! We
already took TWO break tags before
this paragraph!</p>
</body>
</html>
Speaking of effects, if you want words to be in boldface or in italics, you can
enclose them in these tags:
By default, unordered lists are displayed with solid round bullets. But the type
attribute can change the appearance of these bullets. Try any of the following:
<ul type=”disc”>
<ul type=”square”>
<ul type=”circle”>
Ordered or Numbered List
The list is enclosed in <ol> </ol> tags, again with each list item inside
<li> </li> tags. Example:
<ol>Pet hates:
<li>waking up early</li>
<li>drinking hot tea</li>
<li>cleaning my room</li>
<li>the day of doom</li>
</ol>
By default, ordered lists use Arabic numerals with a value “1” for the first list item.
Similar to unordered lists, the appearance of these numerals can change with type. Here
are the options:
<ol type=”1”> for Arabic numerals
<ol type=”i”> or <ol type=”I”> for Roman numerals
<ol type=”a”> or <ol type=”A”> for Alpha numerals
Definition List
The list is enclosed in <dl> </dl> tags. The term to be defined is within
<dt> </dt> tags, followed by the term’s definition inside <dd> </dd>
tags. Example:
<dl>
<dt><strong>stalactite</strong></dt>
<dd>a deposit hanging from the roof or side
of a cave in the shape of an icicle formed by
the partial evaporating of dripping water
containing lime</dd>
<dt><strong>stalagmite</strong></dt>
<dd>a deposit like an upside down stalactite
formed by the dripping of water containing
lime onto the floor of the cave</dd>
</dl>
<p>from <em>Webster’s Elementary
Dictionary</em></p>
Preformatted Text
The preformatted text element – with the <pre> </pre> tags – commands the browser to
display the text in fixed‑width (i.e., monospace or typewriter) typeface and makes it
appear exactly as it was typed in Notepad. This HTML tag enables you to indent text. Try
encoding this:
<pre>
Species Brain weight(g) Body weight(g)
------- ---------------- ---------------
Frog 0.1 18
Human 1400.0 62000
Dolphin 1700.0 160000
</pre>
Horizontal Rule
The horizontal rule element in HTML is a line that can be used to separate different areas
of a Web page and help improve its design. By default, horizontal rules fully expand to the
width of a browser window, appear shaded, and are a few pixels high. It is an empty tag,
thus it is encoded as <hr />.
<html>
<head>
<title>HR</title>
</head>
<body>
<hr />
You can put the horizontal
rule anywhere. =)
<br/> Plus, it expands
when you resize your
window!
<hr />
</body>
</html>
Lesson 3
Experimenting with
Fonts and Colors
Using CSS
External Style Sheet
<html>
<head>
<link rel=”stylesheet” type=”text/css” href=”external.css” />
<title>Stylissimo</title>
</head>
<body>
<h2>Self-Regeneration</h2>
<dl>
<dt><em>phoenix, phenix</em> noun (Egyptian mythology)</dt>
<dd>a bird of gorgeous plumage, sacred to the sun, reborn from the ashes of the
funeral pyre which it made for itself when each life span of 500 or 600 years was
over.</dd>
</dl>
<p>from <em>New Webster’s Dictionary and Thesaurus</em></p>
</body>
</html>
Deprecated Tags and Attributes
Deprecated means that, in a future version of XHTML, none of
these tags will be accepted.
Experimenting
With Images
Background Values
The background of the page can be styled by using the following CSS
properties:
</body></html>
You can format the image’s borders using the
internal style sheet. Some of its properties are:
• border-style = you may choose among these more widely-used
values to control the appearance of the image’s borders:
dashed, dotted, double, solid, or none.
• border-width = you may indicate the thickness of the width of
the image’s borders through these values: thin, medium, or
thick; or through the desired width, which should be in pixels.
• border-color = you may assign any color or the value
transparent to any of the following border-color variations:
border-top-color, border-bottom-color, border-left-color, and
border-right-color.
Lesson 5
Working with
The Box Model
Grouping Selectors
You can group selectors together if they share the same
properties. Just remember to separate each other by a
comma. For example:
Border
Padding
Element
Margin and Padding
.box {
width:300px;
background: cyan;
margin: 3em;
padding:5px;
border-style:dashed;
border-color: #609;
color: blue;
font-family: tahoma;
}
Lesson 6
Links and
More Links
HTML Links
Links or hyperlinks are pointers to the pages
they reference and they are the most
essential ingredients of the Web. Part of the
Web’s success is due to its ability to link a
Web page to other pages.
External Link
The anchor tag has no meaning without attributes.
The hypertext reference or href attribute must
contain a URL for its value, which should be enclosed
in quotes:
<a href=“http://www.gov.ph”>Republic of the
Philippines</a>
Internal Link
For internal links, you can use relative URLs –
meaning you can ask the browser to lead you to the
URL of a link based on the current location of the
HTML page or file inside the anchor opening tag. An
example of this is:
<a href=“project.html”>this links to my project</a>
Link Target: New Window
If you want your link to open the page or file in a new window,
you will need to specify the appropriate attribute and value,
which is target=“_new” inside the anchor opening tag. For
example:
Processing On Line
Forms
Processing On Line
Foms
Online Forms
Content
Input Fields
Submit Query and Reset Buttons
Processing Forms
Online Forms
Online forms are Web pages purposely designed for
gathering information on the Internet. These HTML
documents are sent back to the server once the user
submits them. The main use of online forms is to gather
feedback or opinion from the users for data processing,
usually through a database.
Content
Radio buttons are used when you want the user to select
only one option from a list. The term comes from the
shape of the buttons in a car radio, where you can
choose only one button in order to listen to a station.
<p><b> What type of movie do you mostly prefer to watch?
</b></p>
<input type=”radio” name=”movietype” value=”action” /> Action
<input type=”radio” name=”movietype” value=”comedy” /> Comedy
<input type=”radio” name=”movietype” value=”drama” /> Drama
<input type=”radio” name=”movietype” value=”none” />
None of these
Check boxes
Check boxes are similar to radio buttons, but are used
when you want to let the user select more than one
option among a number of choices.
<p><b>Where do you watch movies? Select all that
apply.</b></p>
<input type=”checkbox” name=”where” value=”cinema” />
Cinema
<input type=”checkbox” name=”where” value=”home” />
Home
<input type=”checkbox” name=”where” value=”computer” />
Computer
<input type=”checkbox” name=”donotwatch”
value=”donotwatch” />
Text areas
Text areas are text fields that have more than one line
for longer text input. Usually, they are used as a
method to send comments or feedback. Here, the tag
changes to text area, as follows:
Processing Forms
To process the form, tags must have the action and method
attributes. These specify to the Web master what the user
entered in the form. The action attribute specifies the name of
the field and should be unique within the form. The method
attribute provides content associated with the action attribute.
Because of all of these requirements, the form opening tag must
be modified into this:
Lesson9
Other Web
Matters
Meta Tags
“Meta” is a Greek term meaning “about” or “beyond.” In HTML, we
have tags that do not affect either the form or content of the Web
page although they have information about it that the users can’t
access just by looking at the browser window display. These are
called meta tags.
<head>
<meta name=”author” content=”Florida V. Ortiz” />
<meta name=”description” content=”I bid you welcome to my personal
site. Godlike Flower. Join me, in my Becoming...” />
<meta name=”generator” content=”Notepad” />
<meta name=”keywords” content=”godlike, ida, rida, florida, valencia,
ortiz, supremo, tasya, pilosopo tasyo, iska, iskolar ng bayan, up student,
philosophy major, filipino site, personal website, articles, profile,
pictures, online diary, ideal philosopher” />
<title>Florida’s Home Page</title>
</head>
Lesson10
Getting Started
With JavaScript
Getting started
with JavaScript
What Is a Script?
What You Should Already Know
The Key to Understanding
JavaScript
What Is a Script?
JavaScript Syntax
Rules and Variables
What Is JavaScript?
Result:
This code outputs this text into the browser
JavaScript Variables
In JavaScript, variables are a container that
contains a value, which can change as required.
Data Types
• character –
• string”
• integer –
• float (or double)
• Boolean
• function
• object
array
• undefined
• null
Declaring Variables
Variables are declared with a var statement. It is always
good practice to pre-define your variables using var. If
you declare a variable inside a function, it can be
accessed anywhere within the function.
</html>
Lesson12
JavaScript Operators
What Is an Operator?
Math/Arithmetic Operator?
Operator Name Example Result
+ Addition myVariable = 3 + 4 myVariable = 7
- Subtraction myVariable = 15 - 7 myVariable = 8
* Multiplication myVariable = 3*5 myVariable = 15
/ Division myVariable = 20 / 4 myVariable = 5
% Modulus myVariable = 24 % 10 myVariable = 4
- Negation myVariable = -10 myVariable = -10
++ Increment
-- Decrement
Sample Code
<script style=”text/javascript”>
var myComparison = 10<=8;
document.write(myComparison);
</script>
Result:
False
Logical/Boolean Operators
&& AND (both statements must be True) True && True True
|| OR (one must be True) True || False True
! NOT (Flips truth value) !True False
Sample
Code <script style=”text/javascript”>
var mylogic = 10<=8 || 10>=8
document.write(myComparison);
</script>
Result:
True
Lesson13
If Statement
If Else Statement
If Else If Statement
Switch Statement
While Loop
For Loop
If Else Statement
The If Else statement is similar to the If
statement, except that we are giving an alternative
instruction in case the argument isn’t True.
IF (CONDITION)
{
STATEMENT IF TRUE
}
ELSE
{
STATEMENT IF FALSE
}
If Else If Statement
But in the real world, you don’t always
evaluate just one condition. Sometimes, you
would need to evaluate more than one or
multiple conditions.
This is possible in JavaScript with the If Else
If statement. The name refers to an If
statement that depends on another If
statement.
LOOPS
• FOR LOOP
• WHILE LOOP
Functions and Events
Functions
Predefined functions
Events
Functions
A function (also known as method) is a
self-contained piece of code that performs
a particular "function" when it is called.
Sometimes there will be text inside the
parentheses. This is known as an
argument. An argument provides
additional information needed by the
function to process.
Dialog Boxes
•Alert function “alert( )”– displays an alert
box with a message defined by the string
message.
• Confirm function “confirm( )” – asks
whether the user would continue or cancel
the action
•Prompt function “prompt( )” – asks for an
input from the user and passes it to the
specified function
Lesson15
JavaScript Objects
JavaScript Objects
•Objects also have methods. Methods are the things that your
object can do.
Example:
document.write(“The method <b>\”write\”</b> writes this text to
the page”);
JavaScript
Independent Objects
JavaScript
Independent Objects
Array Object
Data Object
Math Object
Number Object
String Object
Arrays
Arrays are a fundamental part of most programming
languages and scripting languages. They are basically
an ordered stack of data with the same data type.
Using arrays, you can store multiple values under a
single name.
<script style="text/javascript">
<!--
var myFruit = new Array(“mango”,”guava”,”apple”);
var myString = myFruit.join(“/“);
document.write(myString);
//-->
</script>
Result:
mango/guava/apple
Data Object
JavaScript provides you with the ability to access the date
and time of your user’s local computer, which can be
pretty cool in some cases. This is possible through the
JavaScript date object.
<script style="text/javascript">
<!--
var currentDate = new Date();
var day = currentDate.getDate();
var month = currentDate.getMonth();
var year = currentDate.getYear();
document.write(day + "/" + month + "/" + year)
//-->
</script>
Sample
Codes:
<script style="text/javascript">
<!—
document.write(Math.PI);
//-->
</script>
<script style="text/javascript">
<!—
var myValue = MathPI;
document.write(myValueI);
//-->
</script>
Identify the term described in each item.
1. This is an object in JavaScript that can be invoked without necessarily
creating an instance of it.
2. These are basically an ordered stack of data with the same data type.
3. This is a JavaScript array object method that splits a string using the
specified delimiter and returns the delimited strings in an array.
4. This object has the ability to access the date and time of your user’s
local computer.
5. This sets the minutes in the date object with a value of 0 through 59.
6. This string object returns a substring taken from a string beginning
7. This is used to truncate the last character of all strings elements of
an array.
8. This object has no specific functions, but has associated built-in
functions.
Questions/Comments
What questions or
comments do you
have?