Академический Документы
Профессиональный Документы
Культура Документы
UNIT -1
Introduction To Web Design 5
Web page and Web site - Web publishing Process of Web, publishing,
planning, organizing, Hierarchical, Linear, Webbed. Implementing,
Testing, Maintenance.
UNIT -2
HTML 15
Introduction
Head section – Prologue, Link, Base, Meta, Script, Style
Body Section – Header, Paragraphs, Text Formatting, Linking,
Internal Linking, Embedding Images, Lists, Tables, Frames. Other
Special Tags and Characters
HTML Forms
UNIT -3
Java Script 15
Introduction
Language Elements – Identifiers, Expressions, Keywords, Operators,
Statements, Functions
Object of Java Scripts – Window Object, Document Object, Forms
Objects,
Text Boxes and Text Areas, Buttons, Radio Buttons and Check Boxes,
The
Select Object
Other Object – The Date Object, The Math Object, The String Object,
Regular Expressions, Arrays, Worked Examples
UNIT -4
DHTML 15
Introduction
Cascading Style Sheet (CSS) – Coding, Properties of Text, Property
Values, Other Style Values, In-Line Style Sheet, Embedded Style Sheet,
External Style Sheet, Grouping, Inheritance, Classes as Selector, ID as
Selector, Contextual Selector, Pseudo Classes and Pseudo Elements,
Positioning, Backgrounds, Element Dimensions
DHTML Document Object Model and Collections – Using the
Collection all, Moving object around the documents
Event Handling – Assigning Event Handlers, Even Bubbling
Filters and Transactions
Data Bindings – Using Tabular Data Control, Sorting Data, Dynamic
Sorting, Filtering
UNIT -5
XML Basics 04
Introduction
HTML vs. XML
Syntax of the XML Document
XML Attributes
UNIT -6
Since web publishing does not demand physical materials like ink and
paper, it costs practically nothing to publish the content.
Thus, anyone fulfilling the above three requirements can become a web
publisher. In addition, web publishing brings countless visitors as the
published contents are accessed by global visitors. These benefits of web
publishing opened a new era of personal publishing, which was
unimaginable before.
E-book and blog publishers utilize almost the same web publishing tools
used by the website developers. People who do not have the required
web publishing skills seek the services of professional web publishing
individuals or organizations to host, maintain, and modify their websites,
e-books and blogs.
1. During this phase, the Web designer needs to make decisions about
the Web site content and functionality.
5. You should select a layout for your Web site based on how users
will most easily navigate through the site to complete tasks and
view the Web site contents.
(E) Hierarchical
(F)Linear
A linear Web site layout connects Web pages in a straight line. A
linear Web site layout connects Web pages in a straight line. A linear
Web is appropriate if the information on the Web pages should be read
in a specific order.
Linear Web Site Layout
(G)Webbed Implementing
1. During this phase, the Web designer needs to make decisions about
the Web site content and functionality.
A Web site should be tested at various stages of the Web design and
development. This testing should include a review of page content,
functionality and usability. Some basic steps to test content and
functionality are:
Reviewing for accurate spelling and proofreading content
including page titles.
Checking links to ensure that they are not broken and are linked
correctly
Checking graphics to confirm they display properly and are linked
correctly
Testing forms and other interactive page elements
Testing pages to check for speed of loading on lower speed
connection
Printing each page to check how page s print
Testing each Web in several different browser types and versions
to verify they display correctly
Usability is the measure of how well product, allows users to
accomplish their goals. Usability testing is a method by which users
of a Web site are asked to perform certain tasks in an effort to
measure the ease of use of the product.
(I)Maintenance
Once the Web site testing is complete and any required changes have
been made, the Web site can be implemented. Implementation of a
Web site means publishing the Web site or uploading it into a Web
server.
Once, the Web site has been implemented, its maintenance will
include updating the information content by removing the outdated
one and putting in the new one.
Periodical checking of the links is also necessary to ensure that they
are still active.
Finally, Website monitoring is another key aspect of maintenance.
Usually, the Web servers that host the Web sites keep logs about Web
site usage.
A log is the file that lists all the Web pages that have been requested
from the Web site.
Analyzing the logs allows you to determine the number of visitors to
your site and the browser types and versions they are using, as well as
their connection speeds, most commonly requested pages.
UNIT -2
HTML
Introduction
<html>
<head>
<title>Page title here</title>
</head>
<body>
This is sample text...
<!-- We use this syntax to write comments -->
<!-- Page content and rest of the tags here.... -->
<!-- This is the actual area that gets shown in the browser -->
</body>
</html>
Head section
Example
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
The content of the document......
</body>
</html>
(A)Prologue
It must only appear once, at the top of the page (before any HTML tags).
<!DOCTYPE html>
(B)Link
Example
<link rel="stylesheet" href="mystyle.css">
(C)Base
The <base> element specifies the base URL and base target for all
relative URLs in a page:
Example
<base href="http://www.w3schools.com/images/" target="_blank">
(D)Meta
<meta charset="UTF-8">
<meta name="author" content="Hege Refsnes">
<meta http-equiv="refresh" content="30">
Example
<meta charset="UTF-8">
<meta name="description" content="Free Web tutorials">
<meta name="keywords" content="HTML,CSS,XML,JavaScript">
<meta name="author" content="Hege Refsnes">
(E)Title
Example
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
The content of the document......
</body>
</html>
(F)Style
Example
<style>
body {background-color: powderblue;}
h1 {color: red;}
p {color: blue;}
</style>
(F)Script
Tag Description
<base> Defines a default address or a default target for all links on a page
The <body> Element
The <body>...</body> element defines the BODY section of an
HTML document, which encloses the content to be displayed on
the browser's window.
The <body> tag has the following optional presentation attributes.
All of these presentation attributes are concerned about the
appearance instead of the content, and have been deprecated in
HTML 4 in favor of style sheet.
However, many older textbooks present them in Chapter 1. Hence,
I shall list them here for completeness. BUT do not use these
attributes. I shall describe how to control the appearance
of<body> using CSS very soon.
<h1> defines the most important heading. <h6> defines the least
important heading:
Example
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
(B)Paragraphs
Example
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
(C)Text Formatting
Bold Tags
Tag: <b></b>(Has closing tag) </> means closed.
What it Does: Creates bold text
Code Example: <b>this is bold. </b>
What it looks like:
this is bold.
Italic Tags
Tag: <i></i>(Has closing tag) </> means closed.
What it Does: Creates Italic text.
Code Example: <i> This text is italic. </i>
What it looks like:
This text is italic.
Underline Tags
Tag: <u></u>(Has closing tag) </> means closed.
What it Does: Creates bold text
Code Example: <u>this is unerline. </u>
What it looks like:
this is underline.
(D)Linking
Example
<a href="http://www.w3schools.com">This is a link</a>
(E)Internal Linking
<A>...</A>
Often called anchor tags.
Links can be created using the <A>...</A> tags.
Attributes
HREF="..."
where location is the path and filename to the linked file or image
or specifies the email address prefaced with mailto:
l
NAME="..."
each anchor tag can be given a name - this allows you to link directly to
sections where a named
anchor occurs.
A # (hash) symbol is used before the name in the HREF attribute when
linking.
(F)Embedding Images
.
1. Always use alt tags (alternative text) in images
2. Close your tags </>
<IMG>...</IMG>
Images can be included using the <IMG> tag.
SRC="..." - required
specifies the location/source, or URL, of the image
l
HEIGHT="..."
where the image height can be specified in pixels (e.g. 100)
l
l WIDTH="..."
where the image width can be specified in pixels (e.g. 100)
ALT="..."
used to display some alternative text to the image. A good idea as often
people have images switched off to speed up downloading time. Also
important for partially sighted users with text readers.
l
ALIGN=...
specifies the alignment, TOP , MIDDLE , BOTTOM , LEFT , RIGHT
, TEXTTOP ,
ABSMIDDLE , BASELINE or ABSBOTTOM
l
VSPACE="..."
specifies the number of pixels of vertical space left around an image
l
HSPACE="..."
specifies the number of pixels of horizontal space left around an image
l
BORDER="..."
specifies the number of pixels width for the border around the image.
Default is no border, except
of images which are links. Use BORDER="0" to remove borders
l
NAME="..."
assigns a name to the image, mainly for use with JavaScript for mouse
overs.
l
LOWSRC="..."
allows an initial, usually lower resolution, image to be displayed. Final
image is downloaded after
page layout and other LOWSRC images have been loaded.
(G)Lists
An Unordered List:
Item
Item
Item
Item
An Ordered List:
1. First item
2. Second item
3. Third item
4. Fourth item
Unordered HTML List
An unordered list starts with the <ul> tag. Each list item starts with
the <li> tag.
The list items will be marked with bullets (small black circles) by
default:
Example
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
Unordered HTML List - Choose List Item Marker
Value Description
An ordered list starts with the <ol> tag. Each list item starts with
the <li> tag.
The type attribute of the <ol> tag, defines the type of the list item
marker:
Type Description
type="I" The list items will be numbered with uppercase roman numbers
type="i" The list items will be numbered with lowercase roman numbers
Numbers:
<ol type="1">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
Uppercase Letters:
<ol type="A">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
Lowercase Letters:
<ol type="a">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
Uppercase Roman Numbers:
<ol type="I">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
Lowercase Roman Numbers:
<ol type="i">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
Example
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>
Nested HTML Lists
Example
<ul>
<li>Coffee</li>
<li>Tea
<ul>
<li>Black tea</li>
<li>Green tea</li>
</ul>
</li>
<li>Milk</li>
</ul>
Note: List items can contain new list, and other HTML elements, like
images and links, etc.
Horizontal Lists
Example
<!DOCTYPE html>
<html>
<head>
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333333;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 16px;
text-decoration: none;
}
li a:hover {
background-color: #111111;
}
</style>
</head>
<body>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#news">News</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#about">About</a></li>
</ul>
</body>
</html>
Chapter Summary
Tag Description
Example
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
If you do not specify a border for the table, it will be displayed without
borders.A border is set using the CSS border property:
Example
table, th, td {
border: 1px solid black;
}
Remember to define borders for both the table and the table cells.
If you want the borders to collapse into one border, add the CSS border-
collapse property:
Example
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
HTML Table - Adding Cell Padding
Cell padding specifies the space between the cell content and its borders.
If you do not specify a padding, the table cells will be displayed without
padding.
Example
th, td {
padding: 15px;
}
HTML Table - Left-align Headings
Example
th {
text-align: left;
}
HTML Table - Adding Border Spacing
Border spacing specifies the space between the cells.To set the border
spacing for a table, use the CSS border-spacing property:
Example
table {
border-spacing: 5px;
}
Example
<table style="width:100%">
<tr>
<th>Name</th>
<th colspan="2">Telephone</th>
</tr>
<tr>
<td>Bill Gates</td>
<td>55577854</td>
<td>55577855</td>
</tr>
</table>
HTML Table - Cells that Span Many Rows
<table style="width:100%">
<tr>
<th>Name:</th>
<td>Bill Gates</td>
</tr>
<tr>
<th rowspan="2">Telephone:</th>
<td>55577854</td>
</tr>
<tr>
<td>55577855</td>
</tr>
</table>
HTML Table - Adding a Caption
To add a caption to a table, use the <caption> tag:
Example
<table style="width:100%">
<caption>Monthly savings</caption>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td> Note: The
<td>$100</td> <caption> tag must
</tr> be inserted
<tr> immediately after
the <table> tag.
<td>February</td>
<td>$50</td></tr></table>
A Special Style for One Table
To define a special style for a special table, add an id attribute to the
table:
Example
<table id="t01">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
Now you can define a special style for this table:
table#t01 {
width: 100%;
background-color: #f1f1c1;
}
And add more styles:
table#t01 tr:nth-child(even) {
background-color: #eee;
}
table#t01 tr:nth-child(odd) {
background-color: #fff;
}
table#t01 th {
color: white;
background-color: black;
}
Chapter Summary
Tag Description
formatting
element
(I)Frames
HTML frames are used to divide your browser window into multiple
sections where each section can load a separate HTML document. A
collection of frames in the browser window is known as a frameset. The
window is divided into frames in a similar way the tables are organized:
into rows and columns.
Disadvantages of Frames
There are few drawbacks with using frames, so it's never recommended
to use frames in your webpages:
Some smaller devices cannot cope with frames often because their
screen is not big enough to be divided up.
Sometimes your page will be displayed differently on different
computers due to different screen resolution.
The browser's back button might not work as the user hopes.
There are still few browsers that do not support frame technology.
Creating Frames
To use frames on a page we use <frameset> tag instead of <body> tag.
The <frameset> tag defines how to divide the window into frames.
The rowsattribute of <frameset> tag defines horizontal frames
and cols attribute defines vertical frames. Each frame is indicated by
<frame> tag and it defines which HTML document shall open into the
frame.
Example
Following is the example to create three horizontal frames:
<!DOCTYPE html>
<html>
<head>
<title>HTML Frames</title>
</head>
<frameset rows="10%,80%,10%">
<frame name="top" src="/html/top_frame.htm" />
<frame name="main" src="/html/main_frame.htm" />
<frame name="bottom" src="/html/bottom_frame.htm" />
<noframes>
<body>
Your browser does not support frames.
</body>
</noframes>
</frameset>
</html>
This will produce following result:
Example
Let's put above example as follows, here we replaced rows attribute by
cols and changed their width. This will create all the three frames
vertically:
<!DOCTYPE html>
<html>
<head>
<title>HTML Frames</title>
</head>
<frameset cols="25%,50%,25%">
<frame name="left" src="/html/top_frame.htm" />
<frame name="center" src="/html/main_frame.htm" />
<frame name="right" src="/html/bottom_frame.htm" />
<noframes>
<body>
Your browser does not support frames.
</body>
</noframes>
</frameset>
</html>
This will produce following result:
Attribute Description
rows This attribute works just like the cols attribute and
takes the same values, but it is used to specify the
rows in the frameset. For example to create two
horizontal frames, use rows="10%, 90%". You can
specify the height of each row in the same way as
explained above for columns.
border This attribute specifies the width of the border of
each frame in pixels. For example border="5". A
value of zero means no border.
frameborder This attribute specifies whether a three-dimensional
border should be displayed between frames. This
attrubute takes value either 1 (yes) or 0 (no). For
example frameborder="0" specifies no border.
framespacin This attribute specifies the amount of space between
g frames in a frameset. This can take any integer value.
For example framespacing="10" means there should
be 10 pixels spacing between each frames.
Following are important attributes of <frame> tag:
Attribute Description
Target attribute of frame
Option Description
_parent Loads the page into the parent window, which in the
case of a single frameset is the main browser window.
This entity set contains all the letters used in modern Greek. However, it
does not include Greek punctuation, precomposed accented characters
nor the non-spacing accents (tonos, dialytika) required to compose them.
There are no archaic letters, Coptic-unique letters, or precomposed
letters for Polytonic Greek. The entities defined here are not intended for
the representation of modern Greek text and would not be an efficient
representation; rather, they are intended for occasional Greek letters
used in technical and mathematical works.
<form>
.
form elements
.
</form>
Form elements are different types of input elements, like text fields,
checkboxes, radio buttons, submit buttons, and more.
Type Description
Example
<form>
First name:<br>
<input type="text" name="firstname"><br>
Last name:<br>
<input type="text" name="lastname">
</form>
First name:
Last name:
Note: The form itself is not visible. Also note that the default width of a
text field is 20 characters.
Example
<form>
<input type="radio" name="gender" value="male" checked> Male<br>
<input type="radio" name="gender" value="female"> Female<br>
<input type="radio" name="gender" value="other"> Other
</form>
Male
Female
Other
The Submit Button
Example
<form action="action_page.php">
First name:<br>
<input type="text" name="firstname" value="Mickey"><br>
Last name:<br>
<input type="text" name="lastname" value="Mouse"><br><br>
<input type="submit" value="Submit">
</form>
First name:
Mickey
Last name:
Mouse
Submit
<form action="action_page.php">
If the action attribute is omitted, the action is set to the current page.
The Method Attribute
<form action="action_page.php" method="get">
or:
<form action="action_page.php" method="post">
However, when GET is used, the submitted form data will be visible in
the page address field:
action_page.php?firstname=Mickey&lastname=Mouse
POST has no size limitations, and can be used to send large amounts of
data.
The Name Attribute
If the name attribute is omitted, the data of that input field will not be
sent at all.
This example will only submit the "Last name" input field:
Example
<form action="action_page.php">
First name:<br>
<input type="text" value="Mickey"><br>
Last name:<br>
<input type="text" name="lastname" value="Mouse"><br><br>
<input type="submit" value="Submit">
</form>
Grouping Form Data with <fieldset>
Example
<form action="action_page.php">
<fieldset>
<legend>Personal information:</legend>
First name:<br>
<input type="text" name="firstname" value="Mickey"><br>
Last name:<br>
<input type="text" name="lastname" value="Mouse"><br><br>
<input type="submit" value="Submit">
</fieldset>
</form>
Submit
Attribute Description
accept-charset Specifies the charset used in the submitted form (default: the
page charset).
(default: on).
(default: is url-encoded).
method Specifies the HTTP method used when submitting the form
(default: GET).
novalidate Specifies that the browser should not validate the form.
(default: _self).
UNIT -3
Java Script
Introduction
One of many JavaScript HTML methods is getElementById().
Example
document.getElementById("demo").innerHTML = "Hello JavaScript";
<!DOCTYPE html>
<html>
<body>
</body>
</html>
Example
document.getElementById("demo").style.fontSize = "25px";
JavaScript Can Hide HTML Elements
Example
document.getElementById("demo").style.display="none";
JavaScript Can Show HTML Elements
Example
document.getElementById("demo").style.display="block";
Language Elements
(A)Identifiers
The rules for legal identifier names are the same in JavaScript as
they are in Java and many other languages. The first character must
be a letter, anunderscore (_), or a dollar sign ($).
Note that dollar signs are not legal in identifiers prior to JavaScript
1.1. They are intended for use only by code-generation tools, so
you should avoid using dollar signs in identifiers in the code you
write yourself.
i
my_variable_name
v13
_dummy
$str
this
Use the this keyword to refer to the current object. In
general, this refers to the calling object in a method. Use this either
with the dot or the bracket notation:
this["propertyName"]
this.propertyName
New keyword
You can use the new operator to create an instance of a user-defined
object type or of one of the built-in object types. Use new as follows:
var objectName = new objectType([param1, param2, ..., paramN]);
Super Keyword
The super keyword is used to call functions on an object's parent. It is
useful with classes to call the parent constructor, for example.
super([arguments]); // calls the parent constructor.
super.functionOnParent([arguments]);
(D)Operators
Assignment operators
Comparison operators
Arithmetic operators
Bitwise operators
Logical operators
String operators
Conditional (ternary) operator
Comma operator
Unary operators
Relational operator
Addition
x += y x=x+y
assignment
Subtraction
x -= y x=x-y
assignment
Multiplication
x *= y x=x*y
assignment
Division
x /= y x=x/y
assignment
assignment
Exponentiation
x **= y x = x ** y
assignment
Left shift
x <<= y x = x << y
assignment
Right shift
x >>= y x = x >> y
assignment
Unsigned right
x >>>= y x = x >>> y
shift assignment
Bitwise AND
x &= y x=x&y
assignment
Bitwise XOR
x ^= y x=x^y
assignment
Bitwise OR
x |= y x=x|y
assignment
Comparison operators
A comparison operator compares its operands and returns a logical value
based on whether the comparison is true. The operands can be
numerical, string, logical, or object values.
Examples
Operator Description returning
true
"3" == var1
3 == '3'
var1 <=
Less than or Returns true if the left operand is less
var2
equal (<=) than or equal to the right operand.
var2 <= 5
Arithmetic operator
Operator precedence
member . []
multiply/divide */%
addition/subtraction + -
bitwise-and &
bitwise-xor ^
bitwise-or |
logical-and &&
logical-or ||
conditional ?:
comma ,
(E)Statements
(A)Break
The break statement exits a switch statement or a loop (for, for ...
in, while, do ... while).
When the break statement is used with a switch statement, it breaks
out of the switch block. This will stop the execution of more
execution of code and/or case testing inside the block.
When the break statement is used in a loop, it breaks the loop and
continues executing the code after the loop (if any).
The break statement can also be used with an optional label
reference, to "jump out" of any JavaScript code block (see "More
Examples" below).
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
function myFunction() {
var day;
case 0:
day = "Sunday";
break;
case 1:
day = "Monday";
break;
case 2:
day = "Tuesday";
break;
case 3:
day = "Wednesday";
break;
case 4: Output
break;
case 6:
day = "Saturday";
break;
}
document.getElementById("demo").innerHTML = "Today is " + day;
</script>
</body>
</html>
Continue
The continue statement breaks one iteration (in the loop) if a
specified condition occurs, and continues with the next iteration in
the loop.
<!DOCTYPE html>
<html>
<body>
<p>Click the button to do a loop which will skip the step where i is
equal to 3.</p>
<p id="demo"></p>
<script>
function myFunction() {
var i;
if (i === 3) {
continue;
document.getElementById("demo").innerHTML = text;
}
Click the button to do a loop which will skip
</script> the step where i is equal to 3.
Try it
<!DOCTYPE html>
<html>
<body>
<p>Click the button to loop through a block of code as long as i is
less than 5.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
Click the button to loop through a
<script> block of code as long as i is less than
5.
function myFunction() {
Try it
var text = ""
var i = 0; The number is 0
The number is 1
do { The number is 2
The number is 3
text += "<br>The number is " + i; The number is 4
i++;
} while (i < 5);
document.getElementById("demo").innerHTML = text;
}</script>
</body>
</html>
If else
<!DOCTYPE html>
<html>
<body>
<p>Clck the button to display "Good day", only if the time is less than
20:00.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
var time = new Date().getHours();
if (time < 20) {
document.getElementById("demo").innerHTML = "Good day";
} Clck the button to display "Good day", only if the
time is less than 20:00.
}
Try it
</script>
</body> Good day
</html>
Switch
<p id="demo"></p>
<script>
function myFunction() {
var text;
var fruits = document.getElementById("myInput").value;
switch(fruits) {
case "Banana":
text = "Banana is good!";
break;
case "Orange":
text = "I am not a fan of orange.";
break;
case "Apple":
text = "How you like them apples?";
break;
default:
text = "I have never heard of that fruit...";
}
document.getElementById("demo").innerHTML = text;
}
</script> Write Banana, Orange or Apple in the input
field and click the button.
</body>
The switch statement will execute a block of
</html> code based on your input.
Try it
TRY Catch
Note: The catch and finally statements are both optional, but you need to
use one of them (if not both) while using the try statement.
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
try {
adddlert("Welcome guest!");
}catch(err) {
document.getElementById("demo").innerHTML = err.message;
}</script>
</body>
</html>
(F) Functions
Syntax
function functionName(parameters) {
code to be executed
}
Parameter Values
Parameter Description
variables.
<!DOCTYPE html>
<html>
<body>
<p>This example calls a function which returns the value of PI:</p>
<p id="demo"></p>
<script>
function myFunction() {
return Math.PI;
}
document.getElementById("demo").innerHTML = myFunction();
</script>
This example calls a function which returns the value of
</body> PI:
</html> 3.141592653589793
Object of Java Scripts
(A)Window Object
The window object represents an open window in a browser.
Property Description
defaultStatus Sets or returns the default text in the status bar of a window
pageXOffset Returns the pixels the current document has been scrolled
(horizontally) from the upper left corner of the window
pageYOffset Returns the pixels the current document has been scrolled
(vertically) from the upper left corner of the window
Method Description
prompt() Displays a dialog box that prompts the visitor for input
resizeBy() Resizes the window by the specified pixels
(B)Document Object
document
document
specified text
node
document
adjacent nodes
document.normalizeDocument() Removes empty Text nodes, and joins
adjacent nodes
document
document
is enforced or not
document
code to a document
(C)Forms Objects
Duck
<html> Last name:
Submit
<body>
<h3>A demonstration of how to access a FORM element</h3>
<form id="myForm" action="form_action.asp">
First name: <input type="text" name="fname" value="Donald"><br>
Last name: <input type="text" name="lname" value="Duck"><br>
<input type="submit" value="Submit">
</form>
<p>Click the "Try it" button to get the URL for where to send the form
data when the form above is submitted.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myForm").action;
document.getElementById("demo").innerHTML = x;}
</script>
</body>
</html>
Form Object Properties
action - This specifies the URL and CGI script file name the form
is to be submitted to. It allows reading or changing the ACTION
attribute of the HTML FORM tag.
elements - An array of fields and elements in the form.
encoding - This is a read or write string. It specifies the encoding
method the form data is encoded in before being submitted to the
server. It corresponds to the ENCTYPE attribute of the FORM tag.
The default is "application/x-www-form-urlencoded". Other
encoding includes text/plain or multipart/form-data.
length - The number of fields in the elements array. I.E. the length
of the elements array.
method - This is a read or write string. It has the value "GET" or
"POST".
name - The form name. Corresponds to the FORM Name attribute.
target - The name of the frame or window the form submission
response is sent to by the server. Corresponds to the FORM
TARGET attribute.
Form Objects
radio - A GUI radio button control. Methods are click(), blur(), and
focus(). Attributes:
o checked - Indicates whether the radio button is checked. This
is a read or write value.
o defaultChecked - Indicates whether the radio button is
checked by default. This is a read only value.
o length - The number of radio buttons in a group.
o name - The name of the radio button.
o type - Type is "radio".
o value - A read or write string that specifies the value returned
when the radio button is selected.
Events
onReset
onSubmit
(A)Text Areas
The NAME, ROWS, and COLS values are required. Three optional
handlers may be specified which are "onBlur", "onChange", and
"onSelect". If these handlers are used, the appropriate function must
exist to support the action.
Properties
Methods
Events
onBlur
onChange
onFocus
onSelects
(B)Text Boxes
Properties
Methods
Events
onBlur
onChange
onFocus
onSelect
(D)Buttons
Name Description V
Name Description
(A)Radio Buttons
Checking radio buttons on a form is a little trickier. You have to
loop through each button, testing for a value of checked, which
means it was selected.
one radio button in a group can be selected, so if you find a value
of checked you can break out of the loop.
If no radio button was checked then you can return a value of false.
If any one of them is checked then you can return a value of true.
Here's the code for your radio button function:
If you want to group radio buttons together you give them the
same name. You can then access this name in your code. But
look at what is now on the end:
document.frmOne.payment.length;
When we accessed the text box element like this we had value on the
end. This time we have length. Length is how many radio button are
in the group. We can use this length in the loop:
if ( document.frmOne.payment[i].checked ) {
payment = document.frmOne.payment[i].value;
break;
The loop goes round and around while the variable called i is less
than the length of the radio buttons. Inside of the loop we have this:
if ( document.frmOne.payment[i].checked ) {
payment = document.frmOne.payment[i].value;
break;
document.frmOne.payment.checked
payment = document.frmOne.payment[i].value;
We can then break out of the loop because we know that the
user has selected a radio button.
The IF statement after the loop checks what's inside the variable
called payment. It does exactly the same thing as the email
check box.
The only difference is that it places an error message besides the
radio buttons rather than besides the text box.
Test it out. Click your submit button without selecting a radio
button. You should see this:
The final function we need is for the checkbox. You can have 1 or more
checkboxes on a form. We only have 1, so checking it is fairly
straightforward. If you have more than checkbox, though, you do the
testing in exactly the same way as for radio buttons.
Test it out. Leave the check box unchecked. Click the submit button and
you'll see this:
Properties
Methods
Events
onBlur
onChange
onFocus
Other Object
new Date( )
new Date(milliseconds)
new Date(datestring)
new Date(year,month,date[,hour,minute,second,millisecond ])
Note − Parameters in the brackets are always optional.
Here is a description of the parameters −
No Argument − With no arguments, the Date() constructor
creates a Date object set to the current date and time.
milliseconds − When one numeric argument is passed, it is taken
as the internal numeric representation of the date in milliseconds,
as returned by the getTime() method. For example, passing the
argument 5000 creates a date that represents five seconds past
midnight on 1/1/70.
datestring − When one string argument is passed, it is a string
representation of a date, in the format accepted by
the Date.parse()method.
7 agruments − To use the last form of the constructor shown
above. Here is a description of each argument:
o year − Integer value representing the year. For compatibility
(in order to avoid the Y2K problem), you should always
specify the year in full; use 1998, rather than 98.
o month − Integer value representing the month, beginning
with 0 for January to 11 for December.
o date − Integer value representing the day of the month.
o hour − Integer value representing the hour of the day (24-
hour scale).
o minute − Integer value representing the minute segment of a
time reading.
o second − Integer value representing the second segment of a
time reading.
o millisecond − Integer value representing the millisecond
segment of a time reading.
Date Properties
Here is a list of the properties of the Date object along with their
description.
Property Description
Method Description
Method Description
Property Description
Method Description
Property Description
String Methods
Here is a list of the methods available in String object along with their
description.
Method Description
charAt() Returns the character at the specified
index.
(D)Regular Expressions
or simply
Expressio Description
n
The ranges shown above are general; you could also use the range [0-3]
to match any decimal digit ranging from 0 through 3, or the range [b-v]
to match any lowercase character ranging from b through v.
Quantifiers
The frequency or position of bracketed character sequences and single
characters can be denoted by a special character. Each special character
has a specific connotation. The +, *, ?, and $ flags all follow a character
sequence.
Expressio Description
n
Expression Description
Literal characters
Character Description
Alphanumeri Itself
c
\t Tab (\u0009)
\n Newline (\u000A)
\v Vertical tab (\u000B)
Metacharacters
A metacharacter is simply an alphabetical character preceded by a
backslash that acts to give the combination a special meaning.
For instance, you can search for a large sum of money using the
'\d' metacharacter: /([\d]+)000/, Here \d will search for any string
of numerical character.
The following table lists a set of metacharacters which can be
used in PERL Style Regular Expressions.
Character Description
. a single character
\d a digit (0-9)
\D a non-digit
\W a non-word character
Modifiers
Several modifiers are available that can simplify the way you work
withregexps, like case sensitivity, searching in multiple lines, etc.
Modifier Description
RegExp Properties
Here is a list of the properties associated with RegExp and their
description.
Property Description
Method Description
(E)Arrays
Array Properties
Here is a list of the properties of the Array object along with their
description.
Property Description
Array Methods
Here is a list of the methods of the Array object along with their
description.
Method Description
Introduction
DHTML allows authors to add effects to their pages that are otherwise
difficult to achieve. In short words: scripting language is changing
the DOM and page style.
Simply put, DHTML is the combination of HTML, CSS and JavaScript.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>DHTML example</title>
</head>
<body>
<div id="navigation"></div>
<script>
var init = function () {
myObj = document.getElementById("navigation");
// ... manipulate myObj
};
window.onload = init;
</script>
<!--
Often the code is stored in an external file; this is done
by linking the file that contains the JavaScript.
This is helpful when several pages use the same script:
-->
<script src="myjavascript.js"></script>
</body>
</html>
(A)Coding
CSS use for how to display HTML elements look and formatting
are set using CSS properties.
Using CSS properties you can change every single elements style
can change as you like.
CSS Style sheet create and include with webpage is very easly.
Using CSS Style Sheet update webpage formatting and maintain
consistency across multiple webpages.
CSS properties define either individually or group of element and
best way to done while webpage is being created. Style Sheets
like a 'blueprints' because its hold a group of style related
properties and values.
Define CSS Comments
CSS comment you can define in to your <style> section or Style Sheet
using /* and */ (follwing example line 2 and line 4 comment define).
CSS Comment Example
/* Header style start from here */
#header {
color:purple; /* Default header color */
margin-left:20px;
}
#header .logo {
font-size:16px;
background-color:#FF6633;
}
Advantage of CSS
Easy Manage : CSS with you can better manage whole webpage. CSS
allow to manage entire site elements looks and formatting in single
style sheet file.
Global Change : CSS Style Sheet changes apply to global change for
all webpage. When Style Sheet appear with webpage it's know as
Cascading Style Sheet.
Save time : When we create HTML document, we define separate set
attributes value in each element. but it is limited use. But, CSS give a
lot of flexibility to set properties and values either group of element or
single element. So it's benifit to avoid same code write again and
again.
Easy Maintain/Update : CSS style sheet maintain easier and anytime
you can edit elements properties and values.
3 way to write CSS : You can write CSS styles 3 way Inline element
line (scope is only that element), Internal style write in header section
(scope is only that webpage), or External style sheets write in
external .css extesion files. External style sheets enable you to change
the elements and layout style of all the pages in a Web site, just by
editing one single file.
Page Load Faster : Webpage with style sheets take a bit of second to
load very fastly.
(B)Properties of Text
CSS TEXT properties are various type like text color, text-align,
text-decoration, letter-spacing and many more properties.
Using this propeties you can change the text formatting style.
Following are some CSS text properties listed. Using these
properties you can play with text formatting style.
CSS Color
CSS color property use to set the Text color. The color value can be
specified following three types:
Example Code:
<body>
<p style="color:orange;">CSS TEXT color name orange</p>
<p style="color:#FFA500;">CSS TEXT color hexadecimal code
#FFA500</p>
<p style="color:rgb(255,156,0);">CSS TEXT RGB color code
rgb(255,156,0)</p>
</body>
Run it... »
Example Result:
CSS TEXT color name orange
CSS TEXT color hexadecimal code #FFA500
CSS TEXT RGB color code rgb(255,156,0)
CSS text-align
CSS text-align property use to set the horizontal alignment of text.
text-align posible value center, left, right, or justify.
When you set text-align property value justify than the effect is both
width (left or right) equal like newspaper or books type.
Example Code:
<body>
<p style="text-align:right;">CSS TEXT align right</p>
<p style="text-align:center;">CSS TEXT align center</p>
<p style="text-align:left;">CSS TEXT align left</p>
<p style="text-align:justify;">Hello reader, this ia example of
CSS text-align justify type. Both side left
and right are equal. Its like newspaper or book type. Hello
reader, this ia example of CSS text-align justify type.
Both side left and right are equal. Its like newspaper or book
type. Hello reader, this ia example of CSS text-align
justify type. Both side left and right are equal. Its like newspaper
or book type.</p>
</body>
Run it... »
Example Result:
CSS TEXT align right
CSS TEXT align center
CSS TEXT align left
Hello reader, this ia example of CSS text-align justify type. Both side
left and right are equal. Its like newspaper or book type. Hello reader,
this ia example of CSS text-align justify type. Both side left and right are
equal. Its like newspaper or book type. Hello reader, this ia example of
CSS text-align justify type. Both side left and right are equal. Its like
newspaper or book type.
CSS text-indent
CSS text-indent property is used to set the paragraph first line leftside
leave the blank space.
Example Code:
<body>
<p style="text-indent:35px;">This paragraph is example of CSS
text-indent property and value set 35px (pixel).
So it means paragraph first line leftside leave blank space end of
blank space start a first line paragraph text.</p>
</body>
Run it... »
Example Result:
This paragraph is example of CSS text-indent property and value set
35px (pixel). So it means paragraph first line leftside leave blank space
end of blank space start a first line paragraph text.
CSS text-decoration
CSS text-decoration property use to decorate the text.
CSS text-decoration posible value underline, overline, blink, through
etc.
Example Code:
<body>
<p style="text-decoration:underline;">Text is underline
decorate</p>
<p style="text-decoration:overline;">Text is overline
decorate</p>
<p style="text-decoration:blink;">Text is blink decorate</p>
<p style="text-decoration:line-through;">Text is line delete
decorate</p>
<p style="text-decoration:none;">Text is Nothing any decorate
value</p>
</body>
Run it... »
Example Result:
Text is underline decorate
Text is overline decorate
Text is blink decorate
Text is line delete decorate
Text is nothing any decorate value
CSS text-transformation
CSS text-transformation property use to text transform.
CSS text-transformation posible value capitalize, lowercase and
uppercase in a text.
CSS text-transformation property value capitalize, it means first
letter capital for all word.
Example Code:
<body>
<p style="text-transform:capitalize;">this line transform
capital</p>
<p style="text-transform:lowercase;">this line transform
Lowercase</p>
<p style="text-transform:uppercase;">this line transform
Uppercase</p>
</body>
Run it... »
Example Result:
This Line Transform Capital.
this line transform lowercase.
THIS LINE TRANSFORM UPPERCASE.
CSS letter-spacing
CSS letter-spacing property set blank space between each two letter.
Example Code:
<body>
<p style="letter-spacing:5px">This text is letter spacing</p>
</body>
Run it... »
Example Result:
This text is letter spacing
CSS word-spacing
CSS word-spacing property set blank space between each two word.
Example Code:
<body>
<p style="word-spacing:25px">This text is Word Spacing</p>
</body>
Run it... »
Example Result:
This text is Word Spacing
CSS white-space
CSS white-space property use to set a predefine task. CSS white-space
possible value is normal, pre.
Example Code:
<body>
<p style="white-space:pre">This text is Predefined Area
Predefined area second line</p>
</body>
Run it... »
Example Result:
This text is Predefined Area
CSS text-shadow
CSS text-shadow property is use to decorate text and apply shadow
effect style.
Example Code:
<body>
<p style="text-shadow:4px 4px 8px orange;">This text is
Text Shadow Effect</p>
</body>
Run it... »
Example Result:
This text is Text Shadow Effect
(C)Property Values
CSS background-color
CSS background-color property set background color.
Example Code:
<body>
<p style="background-color:orange;">This paragraph
background color orange</p>
</body>
Run it... »
Example Result:
This paragraph background color orange
CSS background-image
CSS background-image property set image in background.
Example Code:
<body>
<p style="background-
image:url(/jix/img_nat.png);color:#FFFFFF;
height:130px;width:200px;font-size:20px">
This example is Background Image set in element.</p>
</body>
Run it... »
Example Result:
This example is Background Image set in element.
CSS background-repeat
CSS background-repeat property repeat image both side horizontaly
or varticaly. CSS background-repeat property posible value is repeat,
no-repeat, repeat-x (verticaly repeat), and repeat-y (horizontaly
repeat).
Example Code:
<body>
<p style="background-
image:url(/jix/img_nat.png);height:120px; background-repeat:no-
repeat;">This example is Background repeat.</p>
</body>
Run it... »
Example Result:
This example is Background repeat.
CSS background-attachment
CSS background-attachment property use to set background image in
different type attachment like fixed, scroll.
Example Code:
<body>
<p style="background-
image:url(/jix/img_nat.png);height:130px;width:200px;overflow:scrol
l;background-attachment:fixed;color:white;">This example is
Background attachment image is fixed
means image does not moved only fixed attached a image.
background attachment posible value fixed or scroll. you can use this
value and display results.This example is Background attachment
image is fixed means image does not moved only fixed attached
a image. background attachment posible value fixed or scroll. you can
use this value and display results.</p>
</body>
Run it... »
Example Result:
This example is Background attachment image is fixed means image
does not moved only fixed attached a image. background attachment
posible value fixed or scroll. you can use this value and display
results.This example is Background attachment image is fixed means
image does not moved only fixed attached a image. background
attachment posible value fixed or scroll. you can use this value and
display results.
CSS background-position
CSS background-position property use to set background image in
different type position like left, right, center, top, bottom.
Example Code:
<body>
<p style="background-
image:url(/jix/img_nat.png);height:120px;background-repeat:no-
repeat;background-position:150px;"> This example is Background
Position left 150 pixel.</p>
</body>
Run it... »
Example Result:
This example is Background Position left 150 pixel.
Style sheet
1. Selector (Element)
2. Style (Attribute)
3. Property and
4. Value
1. Select the elements on your HTML page that you want to enclose
in a DIV or SPAN tag.
Yes, It's like parent and child... Real world example : your parent
created you, and you inherit some of their appearance or behaviors
(Silly but true..)
2. A car has generic features that every car has.. for example the
Color, horsepower and #of seats... we can also use the tire..
because every car has this properties, and there are some properties
that is specific to a given car... for example the Racecar.
3. it has nitro while truck doesn't have.. Truck have trailer while
Racecar doesn't have.. right? In that case we are going to write
those attributes in each subclass, not in the Superclass..
4. In traditional way of coding.. think that we are making a Car
driving game and we have this classes, without Inheritance we are
going to create different classes and give those classes their
attributes.. it's like we are retyping the same code all over again for
all the same attributes.
5. so why not create a class that would share properties into each of
the Cars?
<html>
<head>
<title>Inheritance</title>
<script type="text/javascript">
function Song(title,type) {
this.title = title;
this.type = type;
this.getTitle=function() {
return "Song: " + this.title + " Type: " + this.type;
}
}
function SubSong(title,type,artist) {
this.artist = artist;
this.toString("Artist is " + artist);
Song.apply(this,arguments);
this.toString = function () {
return "Artist: " + this.artist + " " + this.getTitle();
}
}
SubSong.prototype = new Song();
</head>
<body>
</body>
</html>
(G)Classes as Selector
Example
span#identified {
background-color: DodgerBlue;
}
<span id="identified">Here's a span with some text.</span>
<span>Here's another.</span>
(I)Contextual Selector
Let us write the HTML code to apply the previous style rules:
Document Contextual_selectors.html:
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Contextual selectors</title>
<meta name="Author" content="A. Gklinos" />
<meta http-equiv="Content-Language" content="en" />
<style><!--
table tr td {font-size : 10pt; color: red
}
table a { font-size : 12pt; font-style:italic
}
--></style>
</head>
<body>
<table border="1">
<caption>
<a href="http://www.w3opensource.com/outer.html">outer
elements</a>
</caption>
<tr><td width="100%">The outer element as selector</td></tr>
</table>
<br />
<table border="1">
<caption>
<a href="http://www.w3opensource.com/inner.html">inner
elements</a>
</caption>
<tr>
<td>The inner elements must have as parent the outer
element</td>
</tr>
</table>
</body>
</html>
Running this document with Firefox you will get the following
screen.
Contextual selectors with Classes
Contextual selectors can also be used with classes.
You can create contextual selectors with classes to further control
your web documents styles.
In the following example we create a CSS rule with the class
selector as the element div and contextual selector as the element
h3.
div . italic h3 {font-style: italic}
<body>
<div class="italic">
<h3>Contextual selectors with Classes</h3>
</div>
<div class="Lsize">
Contextual selectors can also be used in conjunction with
classes.
<a
href="http://www.w3opensource.com/selectors_classes.html">
Contextual selectors with Classes</a>
</div>
</body>
</html>
Running this document with Firefox you will get the following
screen.
The style rule and the value of the style property for a contextual
selector concern always the child element and never the parent or
ancestor element.
The contextual selector differs from the generic selector because
the first contains one or more parent elements.
In case we declared a style rule with a contextual selector to set a
value for a property of an element and through a generic selector
we have created a rule that sets value for another property of the
same element, then the setting of the contextual selector will be
done first as a more specific declaration for the element.
The contextual selectors can be defined with simple element
names, names of classes, id names or as a combination of them.
Grouping Contextual selectors
We can create groups of contextual selectors,
but our reference must follow the sequence of nested tags that the
HTML structure needs as we have mentioned previously.
Each group of contextual selectors is separated from the others
by comma (,).
Look at the following example:
h2 b, h3 b, p em, p i { color: blue }
This shows that you have to follow the hierarchic structure of the
HTML elements for each group of contextual selectors. You might
want to use the separate syntax for the declaration above. In this
case you could write analytically in separate style rules the previous
grouped style rule, as below:
h2 b { color: blue
}
h3 b { color: blue
}
p em { color: blue
}
p i { color: blue
}
Now your HTML is simpler and it is clear that the CSS follows the
HTML structure.
(J)Pseudo Classes and Pseudo Elements
Mouse Over Me
Syntax
selector:pseudo-class {
property:value;
}
Anchor Pseudo-classes
Example
/* unvisited link */
a:link {
color: #FF0000;
}
/* visited link */
a:visited {
color: #00FF00;
}
/* selected link */
a:active {
color: #0000FF;
}
When you hover over the link in the example, it will change color:
Example
a.highlight:hover {
color: #ff0000;
}
Hover on <div>
div:hover p {
display: block;
}
CSS - The :first-child Pseudo-class
In the following example, the selector matches any <p> element that is
the first child of any element:
Example
p:first-child {
color: blue;
}
Match the first <i> element in all <p> elements
In the following example, the selector matches the first <i> element in
all <p> elements:
Example
p i:first-child {
color: blue;
}
In the following example, the selector matches all <i> elements in <p>
elements that are the first child of another element:
Example
p:first-child i {
color: blue;
}
Example
<html>
<head>
<style>
q:lang(no) {
quotes: "~" "~";
}
</style>
</head>
<body>
<p>Some text <q lang="no">A quote in a paragraph</q> Some
text.</p>
</body>
</html>
All CSS Pseudo Classes
children
focus
invalid value
element
"required" attribute
"readonly" attribute
valid value
element
element
selected by a user
What are Pseudo-Elements?
Syntax
selector::pseudo-element {
property:value;
}
The single-colon syntax was used for both pseudo-classes and pseudo-
elements in CSS2 and CSS1.
The following example formats the first line of the text in all <p>
elements:
Example
p::first-line {
color: #ff0000;
font-variant: small-caps;
}
font properties
color properties
background properties
word-spacing
letter-spacing
text-decoration
vertical-align
text-transform
line-height
clear
The following example formats the first letter of the text in all <p>
elements:
Example
p::first-letter {
color: #ff0000;
font-size: xx-large;
}
Note: The ::first-letter pseudo-element can only be applied to block-
level elements.
font properties
color properties
background properties
margin properties
padding properties
border properties
text-decoration
vertical-align (only if "float" is "none")
text-transform
line-height
float
clear
Example
p.intro::first-letter {
color: #ff0000;
font-size:200%;
}
The example above will display the first letter of paragraphs with
class="intro", in red and in a larger size.
Multiple Pseudo-elements
Example
p::first-letter {
color: #ff0000;
font-size: xx-large;
}
p::first-line {
color: #0000ff;
font-variant: small-caps;
}
The following example inserts an image before the content of each <h1>
element:
Example
h1::before {
content: url(smiley.gif);
}
The following example inserts an image after the content of each <h1>
element:
Example
h1::after {
content: url(smiley.gif);
}
CSS - The ::selection Pseudo-element
Example
::selection {
color: red;
background: yellow;
}
All CSS Pseudo Elements
<p> element
selected by a user
children
focus
invalid value
element
"required" attribute
"readonly" attribute
valid value
(K)Positioning
static
relative
fixed
absolute
Elements are then positioned using the top, bottom, left, and right
properties. However, these properties will not work unless
the position property is set first. They also work differently depending
on the position value.
position: static;
Static positioned elements are not affected by the top, bottom, left, and
right properties.
Example
div.static {
position: static;
border: 3px solid #73AD21;
}
position: relative;
Example
div.relative {
position: relative;
left: 30px;
border: 3px solid #73AD21;
}
position: fixed;
A fixed element does not leave a gap in the page where it would
normally have been located.
Notice the fixed element in the lower-right corner of the page. Here is
the CSS that is used:
Example
div.fixed {
position: fixed;
bottom: 0;
right: 0;
width: 300px;
border: 3px solid #73AD21;
}
This <div> element has position: fixed;
position: absolute;
Example
div.relative {
position: relative;
width: 400px;
height: 200px;
border: 3px solid #73AD21;
}
div.absolute {
position: absolute;
top: 80px;
right: 0;
width: 200px;
height: 100px;
border: 3px solid #73AD21;
}
Overlapping Elements
This is a heading
Because the image has a z-index of -1, it will be placed behind the text.
Example
img {
position: absolute;
left: 0px;
top: 0px;
z-index: -1;
}
Property Description
(L)Backgrounds
background-color
background-image
background-repeat
background-attachment
background-position
Background Color
Example
body {
background-color: lightblue;
}
In the example below, the <h1>, <p>, and <div> elements have different
background colors:
Example
h1 {
background-color: green;
}
div {
background-color: lightblue;
}
p {
background-color: yellow;
}
Background Image
Example
body {
background-image: url("paper.gif");
}
Example
body {
background-image: url("bgdesert.jpg");
}
Example
body {
background-image: url("gradient_bg.png");
}
Example
body {
background-image: url("gradient_bg.png");
background-repeat: repeat-x;
}
Example
body {
background-image: url("img_tree.png");
background-repeat: no-repeat;
}
In the example above, the background image is shown in the same place
as the text. We want to change the position of the image, so that it does
not disturb the text too much.
Example
body {
background-image: url("img_tree.png");
background-repeat: no-repeat;
background-position: right top;
}
To specify that the background image should be fixed (will not scroll
with the rest of the page), use the background-attachment property:
Example
body {
background-image: url("img_tree.png");
background-repeat: no-repeat;
background-position: right top;
background-attachment: fixed;
}
When using the shorthand property the order of the property values is:
background-color
background-image
background-repeat
background-attachment
background-position
It does not matter if one of the property values is missing, as long as the
other ones are in this order.
Property Description
background Sets all the background properties in one declaration
(M)Element Dimensions
CSS Layout - Horizontal & Vertical Align
In CSS, several properties can be used to align elements horizontally
and vertically.
Center Align Elements
Setting the width of the element will prevent it from stretching out to the
edges of its container.
The element will then take up the specified width, and the remaining
space will be split equally between the two margins:
Example
.center {
margin: auto;
width: 50%;
border: 3px solid green;
padding: 10px;
}
Example
.center {
text-align: center;
border: 3px solid green;
}
Center an Image
Example
img {
display: block;
margin: auto;
width: 40%;
}
Example
.right {
position: absolute;
right: 0px;
width: 300px;
border: 3px solid #73AD21;
padding: 10px;
}
Example
body {
margin: 0;
padding: 0;
}
.container {
position: relative;
width: 100%;
}
.right {
position: absolute;
right: 0px;
width: 300px;
background-color: #b0e0e6;
}
Example
.right {
float: right;
width: 300px;
border: 3px solid #73AD21;
padding: 10px;
}
There is also a problem with IE8 and earlier, when using float. If the !
DOCTYPE declaration is missing, IE8 and earlier versions will add a
17px margin on the right side. This seems to be space reserved for a
scrollbar. So, always set the !DOCTYPE declaration when using float:
Example
body {
margin: 0;
padding: 0;
}
.right {
float: right;
width: 300px;
background-color: #b0e0e6;
}
I am vertically centered.
Example
.center {
padding: 70px 0;
border: 3px solid green;
}
Example
.center {
padding: 70px 0;
border: 3px solid green;
text-align: center;
}
Center Vertically - Using line-height
Example
.center {
line-height: 200px;
height: 200px;
border: 3px solid green;
text-align: center;
}
Example
.center {
height: 200px;
position: relative;
border: 3px solid green;
}
.center p {
margin: 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
DHTML Document Object Model and Collections
<HTML>
<BODY>
<DIV>
<P>Some text in a
<B>paragraph</B>
</P>
<IMG id=image1 src="mygif.gif">
</DIV>
<IMG id=image2 src="mygif.gif">
</BODY>
</HTML>
As of December 2011, this topic has been archived and is no longer
actively maintained. For more information, see Archived Content. For
information, recommendations, and guidance regarding the current
version of Windows Internet Explorer, see Internet Explorer Developer
Center.
This section contains a list of the collections exposed by the Dynamic
HTML (DHTML) Object Model.
Collections
Topic Contents
If you like working with animations, you'll be glad to know that with
DHTML, the entire web page is now your drawing board! You can
create content that fly all over the screen freely. In Netscape, this is done
by manipulating the left and top attributes of the <layer> tag. In IE 4, the
same thing is accomplished by altering the pixelLeft and pixelTop
properties of the style object.
-Moving elements in NS 4
Recall that layers support the left and top property, which controls its
offset from the document's upper left corner. Well, by using simple math
and a couple of lines of script, we can dynamically update these
properties so the layer moves! The below example changes the left
property of a layer so it moves horizontally when a button is pressed.
function come_back(){
clearTimeout(moveid)
document.space.left=128
}
</script>
<form>
<input type="button" value="Move" onClick="moving()">
<input type="button" value="Come back" onClick="come_back()">
</form>
See, all I did was continuously add to the left property of "space" to
move it, and set the property back to its original value when I want the
layer returned back to its initial location.
-Moving elements in IE 4
By the way, the day when NS and IE agree upon one implementation of
DHTML is the day I can stop writing two versions of everything (just
letting out a little frustration). Moving an element in IE 4 involves
basically first wrapping that element either inside a positioned span or
div, then changing the span or div's pixelLeft and pixelTop properties. It
sounds complicated, but is actually very simple:
<div id="spaceship" style="position:relative">
<img src="TN00018A.gif">
</div>
<script>
function moving2(){
if (spaceship.style.pixelLeft<1000)
spaceship.style.pixelLeft+=5
moveid2=setTimeout("moving2()",50)
}
function come_back2(){
clearTimeout(moveid2)
spaceship.style.pixelLeft=0
}
</script>
<form>
<input type="button" value="Move" onClick="moving2()">
<input type="button" value="Come back" onClick="come_back2()">
</form>
What I did first was set the outside <div> called "spaceship" to a
position of relative, which is necessary to make the element movable
(you could also set it to a value of "absolute"). Then, by manipulating
the pixelWidth property of it's style object, the element moves.
Event Handling
(A)Assigning Event Handlers
Thanks to event handling, our scripts are more interactive and are
able to perform certain actions depending on the user's.
Let's first review (for most of us, at least) the 2 common and
conventional ways of setting up an event handler- via HTML, or
scripting. In both cases, a function or code is attached at the end, which
is executed when the handler detects the specified event.
We can define an event handler directly inside the relevant HTML tag,
by embedding it as a attribute. A piece of JavaScript is also included to
tell the browser to perform something when the event occurs. For
example,
Demo:
Freewarejava.com
2) Via scripting
You can also assign and set up event handlers to elements using
scripting, and inside your script . This allows for the event handlers to be
dynamically set up, without having to mess around with the HTML
codes on the page.
<HTML>
<BODY>
<DIV id=OuterDiv style="background-color: red"
onmouseover="alert(window.event.srcElement.id);">
This is some text
<IMG id=InnerImg>
</DIV>
</BODY>
</HTML>
Bubble event
Filters
Filters often create effects that can be generated with script. This
raises the question, "Why use filters if script can do the job?"
There are several reasons for using filters.
The most important is because they don't require script. For better
or worse, many HTML authors do not use scripting. Filters are a
convenient package for the same functionality that scripting
provides.
Another benefit of filters is that they are easier to author and can
be applied to entire classes of elements, because they use the
declarative and inherited syntax of CSS.
Filters and transitions display properly only on systems that have
the color palette set to display 256 colors or more.
Almost any object can have filters applied to it. However, the
object that the filter is applied to must have layout before the filter
effect will display.
Put simply, having layout means that an object has a defined
height and width. Some objects, like form controls, have layout by
default.
All other filterable objects gain layout by setting
the height or width property, setting the position property
to absolute, setting the writingMode property to tb-rl, or setting
the contentEditable property to true.
You can also apply a filter to the BODY element.
The BODY element automatically has layout because it
specifically contains the client area of the window.
However, doing so causes some filters to change when the
window is resized by the user.
One way to avoid this is to apply the filter to a DIV that contains
all of the elements of the document.
The following example shows how to work around applying a
filter to the BODY element.
<ELEMENT STYLE="filter:
progid:DXImageTransform.Microsoft.filtername(sProperties)" >
4.0 filter
Alternate 5.5 implementation
name
alpha DXImageTransform.Microsoft.Alpha
BlendTrans DXImageTransform.Microsoft.Fade
blur DXImageTransform.Microsoft.MotionBlur
chroma DXImageTransform.Microsoft.Chroma
dropShadow DXImageTransform.Microsoft.DropShadow
FlipH DXImageTransform.Microsoft.BasicImage(rotation=2,
mirror=1)
FlipV DXImageTransform.Microsoft.BasicImage(mirror=1)
glow DXImageTransform.Microsoft.Glow
Gray DXImageTransform.Microsoft.BasicImage(grayscale=1)
Invert DXImageTransform.Microsoft.BasicImage(invert=1)
light DXImageTransform.Microsoft.Light
mask DXImageTransform.Microsoft.MaskFilter
shadow DXImageTransform.Microsoft.Shadow
wave DXImageTransform.Microsoft.Wave
Xray DXImageTransform.Microsoft.BasicImage(xray=1)
Transactions
Transitions are time-varying filters that affect how a change of
content is displayed. One example is changing the src attribute of
an image to display a new image on-screen.
A transition provides an animated effect to display the new image.
You can also apply transitions to make an object fade in or fade
out by changing the visibility property.
Transitions have methods and events to manage the timing of the
effect. When a filter completes a display update or a transition
finishes playing, the onfilterchange event is fired.
By adding an onfilterchange event handler to capture the
completion of one transition, you can chain transitions together so
they start one after another.
The event object supplies the necessary information about the filter
and the object involved. You can use the event object to access
the srcFilter property.
A transition's apply method freezes the appearance of an object
when applying a transition. This allows changes to be made
without affecting the display immediately.
The play method then invokes the transition. At any time, the
script can terminate the transition by calling thestop method. The
following example shows how to perform an automatic slide show
of images.
<HTML>
<HEAD><TITLE>Transition Fade Demo</TITLE>
<SCRIPT LANGUAGE="JavaScript">
var fRunning = 0
function startTrans()
{
if (fRunning == 0)
{
fRunning = 1
SampleID.filters.item(0).Apply();
SampleID.src = "sunset.jpg";
SampleID.filters.item(0).Play()
}
}
</SCRIPT>
<SCRIPT for="SampleID" event="onfilterchange">
fRunning = 0
</SCRIPT>
</HEAD>
<BODY>
<IMG id="SampleID" src="beach.jpg"
style="filter:progid:DXImageTransform.Microsoft.Fade(duration=3)"
onclick="startTrans()"><BR>
Click image for Transition to Fade.
</BODY>
</HTML>
syntax
Transition
Property Alternate 5.5 implementation
Value
0 - Box in DXImageTransform.Microsoft.Iris(irisstyle='SQUARE',
motion='in')
2 - Circle DXImageTransform.Microsoft.Iris(irisstyle='CIRCLE',
in motion='in')
3 - Circle DXImageTransform.Microsoft.Iris(irisstyle='CIRCLE',
out motion='out')
4 - Wipe up DXImageTransform.Microsoft.Blinds(direction='up',
bands=1)
5 - Wipe DXImageTransform.Microsoft.Blinds(direction='down',
down bands=1)
6 - Wipe DXImageTransform.Microsoft.Blinds(direction='right',
right bands=1)
7 - Wipe DXImageTransform.Microsoft.Blinds(direction='left',
left bands=1)
8 - Vertical DXImageTransform.Microsoft.Blinds(direction='right')
blinds
9- DXImageTransform.Microsoft.Blinds(direction='down')
Horizontal
blinds
10 - DXImageTransform.Microsoft.CheckerBoard(direction='ri
Checkerbo ght')
ard across
11 - DXImageTransform.Microsoft.CheckerBoard(direction='d
Checkerbo own')
ard down
12 - DXImageTransform.Microsoft.RandomDissolve
Random
dissolve
13 - Split DXImageTransform.Microsoft.Barn(orientation='vertical',
vertical in motion='in')
14 - Split DXImageTransform.Microsoft.Barn(orientation='vertical',
vertical out motion='out')
15 - Split DXImageTransform.Microsoft.Barn(orientation='horizont
horizontal al', motion='in')
in
16 - Split DXImageTransform.Microsoft.Barn(orientation='horizont
horizontal al', motion='out')
out
17 - Strips DXImageTransform.Microsoft.Strips(motion='leftdown')
left down
18 - Strips DXImageTransform.Microsoft.Strips(motion='leftup')
left up
19 - Strips DXImageTransform.Microsoft.Strips(motion='rightdown')
right down
20 - Strips DXImageTransform.Microsoft.Strips(motion='rightup')
right up
21 - DXImageTransform.Microsoft.RandomBars(orientation='
Random horizontal')
bars
horizontal
22 - DXImageTransform.Microsoft.RandomBars(orientation='
Random vertical')
bars
vertical
Implementation:
CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83
First, let us consider a simple example where I store my name and age in
a text file data1.txt. Here is the file:
data1.txt:
1name|age
2~Premshree Pillai~|~19~
Now, I will extract this data and display it in a web page as follows :
Note the attributes within the SPAN tags. DATASRC specifies the
data source to use, which is the same as the ID of the object we
have initialized (here, 'data1').
1. OOP Table Sorting
id colour random
1 green 81.63
2 red 70.7
3 yellow 71.09
4 orange 11.99
5 purple 81.53
6 red 62.25
7 red
8 orange 57
9 blue 49.42
10 orange 25
11 purple 35.43
12 yellow 50.76
13 orange 35.43
14 green 5.81
15 green 80.83
16 yellow 74.47
17 red 86.3
18 purple 25.17
19 orange 49.74
20 purple 37.42
colour
Sort by DESC?
(C)Dynamic Sorting
The second method will show the new data binding facility
available in Microsoft Internet Explorer 4.
Table Sorting
Therefore if you click one of the column headings the document will be
redisplayed, showing the table sorted by the column selected.
<SCRIPT LANGUAGE="JavaScript"><!--
function myObject(number,text,date,name) {
this.number = number;
this.text = text;
this.date = date;
this.name = name;
}
var objectArrayIndex = 0;
var myObjectArray = new Array();
function showObjectArray(object,length) {
var output = '<CENTER><TABLE BORDER=1>';
output += '<TR>' +
'<TH><A HREF="sort.htm?number">number<\/A><\/TH>' +
'<TH><A HREF="sort.htm?text">text<\/A><\/TH>' +
'<TH><A HREF="sort.htm?date">date<\/A><\/TH>' +
'<TH><A HREF="sort.htm?name">name<\/A><\/TH>' +
'<\/TR>';
for (var i=0; i<length; i++)
output += '<TR>' +
'<TD>' + object[i].number+ '<\/TD>' +
'<TD>' + object[i].text + '<\/TD>' +
'<TD>' + object[i].date + '<\/TD>' +
'<TD>' + object[i].name + '<\/TD>' +
'<\/TR>';
output += '<\/TABLE><\/CENTER>';
document.write(output);
}
function myObjectBubbleSort(arrayName,length,property) {
for (var i=0; i<(length-1); i++)
for (var j=i+1; j<length; j++)
if (eval('arrayName[j].' + property + '<arrayName[i].' +
property)) {
var dummy = arrayName[i];
arrayName[i] = arrayName[j];
arrayName[j] = dummy;
}
}
myObjectArray[objectArrayIndex++] = new
myObject(100,'abc','19971104','Me');
myObjectArray[objectArrayIndex++] = new
myObject(400,'zzz','19961003','You');
myObjectArray[objectArrayIndex++] = new
myObject(300,'fox','19950902','Them');
myObjectArray[objectArrayIndex++] = new
myObject(50,'bad','19981201','Us');
if (sortProperty.length != 0)
myObjectBubbleSort(myObjectArray,objectArrayIndex,sortProperty);
showObjectArray(myObjectArray,objectArrayIndex);
//--></SCRIPT>
(E)Filtering
Features Description
Multilevel Drop
There can be multilevel menus - create as many
Down List
rows of the menu as necessary. Any submenu in
and
its turn can include different number of
Multicolumn
columns.
Dhtml Menu Script
Orientation of the
Create both horizontal and vertical menus and
Menu.
submenus with any amount of menus on one
Several Menus on
page.
One Page
Any HTML Code Insert any HTML code inside the dropdown
menu item - be it a form or a picture, a flash-
object or a text. This ability allows you to create
various menus of any complexity.
Size and You can set the size of the menu in pixels,
Positioning percent or other units.
The menu may have an absolute or relative
position (it can be inserted into the table).
Fonts, Borders and Use any necessary font of any color, size and
Background Colors font decoration.
Create any available type, thickness and color
of a menu's frame.
Choose any color for backgrounds of submenus
and items.
Introduction
What is XML?
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
Output:
Note
To: Tove
From: Jani
Reminder
But still, the XML above does not DO anything. XML is just
information wrapped in tags.
The tags in the example above (like <to> and <from>) are not defined in
any XML standard. These tags are "invented" by the author of the XML
document.
HTML works with predefined tags like <p>, <h1>, <table>, etc.
With XML, the author must define both the tags and the document
structure.
XML is Extensible
<note>
<date>2015-09-01</date>
<hour>08:30</hour>
<to>Tove</to>
<from>Jani</from>
<body>Don't forget me this weekend!</body>
</note>
Old Version
Note
To: Tove
From: Jani
Head: (none)
New Version
Note
To: Tove
From: Jani
Create short and simple names, like this: <book_title> not like this:
<the_title_of_the_book>.
Avoid ".". If you name something "first.name", some software may think
that "name" is a property of the object "first".
Non-English letters like éòá are perfectly legal in XML, but watch out
for problems if your software doesn't support them.
Naming Styles
There are no naming styles defined for XML elements. But here are
some commonly used:
<price>29.99</price>
text
attributes
other elements
or a mix of the above
<bookstore>
<book category="children">
<title>Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="web">
<title>Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>
<element></element>
<element />
<note>
<to>Tove</to>
<from>Jani</from>
<body>Don't forget me this weekend!</body>
</note>
MESSAGE
To: Tove
From: Jani
Imagine that the author of the XML document added some extra
information to it:
<note>
<date>2008-01-10</date>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
No. The application should still be able to find the <to>, <from>, and
<body> elements in the XML document and produce the same output.
For a person's gender, the <person> element can be written like this:
<person gender="female">
or like this:
<person gender='female'>
If the attribute value itself contains double quotes you can use single
quotes, like in this example:
<person gender="female">
<firstname>Anna</firstname>
<lastname>Smith</lastname>
</person>
<person>
<gender>female</gender>
<firstname>Anna</firstname>
<lastname>Smith</lastname>
</person>
<note date="2008-01-10">
<to>Tove</to>
<from>Jani</from>
</note>
<note>
<date>2008-01-10</date>
<to>Tove</to>
<from>Jani</from>
</note>
<note>
<date>
<year>2008</year>
<month>01</month>
<day>10</day>
</date>
<to>Tove</to>
<from>Jani</from>
</note>
Avoid XML Attributes?
<note day="10" month="01" year="2008"
to="Tove" from="Jani" heading="Reminder"
body="Don't forget me this weekend!">
</note>
<messages>
<note id="501">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
<note id="502">
<to>Jani</to>
<from>Tove</from>
<heading>Re: Reminder</heading>
<body>I will not</body>
</note>
</messages>
The id attributes above are for identifying the different notes. It is not a
part of the note itself.
What I'm trying to say here is that metadata (data about data) should be
stored as attributes, and the data itself should be stored as elements.
UNIT -6
FTP server: ftp://demozilla.examplehostingprovider.net
User: demozilla
Password: quickbrownfox
To publish on the web, put your files into
the Public/htdocs directory.
Let's first look at http://demozilla.examplehostingprovider.net/ — as you
can see, so far there is nothing there:
Note: Depending on your hosting provider, most of the time you'll see a
page saying something like “This website is hosted by [Hosting
Service].”
To connect your FTP client to the distant server, press the "Create an
account..." button and fill in the fields with the information furnished by
the hosting provider:
On the left, you see your local files. Navigate into the directory
where you store your website (in this case, mdn).
On the right, you see remote files. We are logged into our distant
FTP root (in this case, users/demozilla)
You can ignore the bottom zone for now. It's a live log of every
interaction between your FTP client and the server.
Uploading to the server
As you remember, our hosting provider told us that our files have to be
stored in the Public/htdocs directory, so navigate there in your right
pane:
Now, to upload your files to the server, drag-and-drop them from the left
pane to the right pane:
1.
Lo
gin into your cPanel. Click the File Managerbutton in the Files section.
2.
Navigate to the directory you want to upload a file to and click
the Upload link at the top of the File Manager. This will open an upload
page in a new tab.
3. Drag and drop your file into the window, or click Select File to
browse your computer for the file you want to upload. Check the
available box if you want to overwrite files that already exist in the
upload folder.
4. Your file will then upload. You will see a "100%" message when
the upload completes.
2. Navigate your files in the third window on the left underneath the
"Local Site:" box where its says"Filename".
Drag the file you want to upload to the server from the "Local Site" to
the "Remote Site".
The File will upload and you will see the file in the list of files in the
directory where you dragged the file to.
Using a program like Notepad++
Notepad++ is a program that allows you to edit your site and upload and
create files on the server. It is similar to HTML editor programs
like Edit Plus or DreamWeaver. Below will explain how to create a
file on your server with Notepad++.
Now you will see the file in the folder location on the server.
Web hosting
web server which already has full LAMP stack on it. As example
in this article, we use Ubuntu 14 with MySQL and Apache2 as
web server.
root access to this web server
root access to MySQL database on this server
What we actually would do? When you want to add new website into
your server, there are following three steps to consider:
Note, it doesn't matter in what sequence you are following these three
steps, as long as they all completed. And once all these steps completed,
you are good to go with installation of your CMS as per its
documentation.
All actions shown as performed under root account. Remember, it's
best practice to use regular account with sudo rather than root to
perform any changes in your system.
mkdir /var/www/cutepuppies
Give ownership of the directory to the Apache web user (which is www-
data)
Also, if you action not under root account, add your username to the web
group:
cp 000-default.conf cutepuppies.conf
Open your new configuration file and change following parameters as
per below:
ServerName cutepuppies.com
Server Alias www.cutepuppies.com
DocumentRoot /var/www/cutepuppies
<Directory /var/www/cutepuppies>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
a2ensite cutepuppies.conf
Database name: dbcutepups
Database user: dbuser
DB user's password: password123
Log into MySQL using your MySQL root credentials:
mysql -u root -p
mysql>
Each time you want to add new website into your server, follow
described instructions again. If everything is working properly, all
your websites located on the server should be accesible.
Ultimate Guide to Web Hosting
Most people never really think about where a website is, or even what a
website is. I turn on my computer, open a browser, and go to Google or
Amazon or Yahoo. But what am I doing when I “visit” a website? If I’m
a visitor, where have I gone? And if it is a “site,” where is it located?
What will you learn in this chapter?
Skip this chapter if… You have used web hosting before and have a
good understanding of what a website is and how they work.
What is a website?
Running a website
Web hosting companies have solved this problem for you. They have
bought the big expensive computers, they have set them up to work for
running a website, they have made sure they have a fast connection to
the internet. They’ve done all the work.
When you get a web hosting plan, you are borrowing a bit of one of their
computers (or a whole one, sometimes). This lets you put the files and
software needed to run your website somewhere that it can easily be
accessed by anyone who wants to view it. To make this easier for you,
they also provide tools for managing your piece of the computer and for
building and running your website.
When you use a web hosting company for your website, your website
isn’t in a cloud somewhere or floating in an alternate dimension. It is a
collection of real, actual computer files sitting on a real actual computer
somewhere, in a real building. Where that building is, and what that
computer looks like will depend on which hosting company you use.
And you may never see the computer or even know where in the world it
is. But it’s not magic, and it’s not that much different than the computer
you are using right now.
Summary
A website is a collection of files that sit on a computer. For a website to
work well, a regular desktop computer isn’t a good choice. Web hosting
companies provide fast, powerful computers so that anyone can run a
website without having any special knowledge or buying any special
equipment.
Chapter 2: Different Types of Hosting
When you start looking to purchase a web hosting plan, it’s easy to start
getting overwhelmed by all the different options available. Rather than
trying to sort out what to buy while reading feature lists written by
marketers, it’s better to start by figuring what kind of hosting you need.
What will you learn in this chapter?
The difference between shared, dedicated, and VPS hosting.
What “cloud based” hosting is.
What managed hosting is, and why you may or may not need it.
How to decide what type of hosting plan is right for you.
Shared Hosting
The other major advantage to a dedicated server is that you are the only
one consuming server resources. This significantly increases your speed
and performance.
Of course, if you are able to do anything you want on your server, you
also become responsible for doing pretty much everything that needs to
be done. This includes keeping all the software up to date and debugging
issues if you accidentally create any weird conflicts or problems.
Dedicated server hosting can be very expensive also. With shared
hosting, there might be 100 customers on a single server. With a
dedicated server, you are the only one — and the difference in cost
reflects that.
The problem with both dedicated servers and conventional VPS and
shared hosting plans is that eventually — if there’s enough traffic — you
will hit the physical limitations of the actual server. We’re talking about
a real machine with real limitations on how much memory it can use,
how much storage it can hold, and how many requests it can handle.
Most websites never hit these limits, and shared or VPS hosting is more
than adequate. But some sites regularly get tens of thousands of visits a
day, and other sites with less regular traffic occaisionally have huge
spikes that can’t be predicted, like when a piece of content suddenly
goes viral.
Because of these hosting realities, hosting companies offer something
that usually goes by a name like “scalable VPS hosting” or “cloud based
hosting” or “scalable cloud-based hosting.”
“The Cloud” is sort of a marketing fiction, and sort of a metaphor. It’s
easy to get confused about what this means. The truth is, it means
different things in different contexts.
Generally, with regards to web hosting, “cloud” means that a large
number of computers are all clustered together, and any applications
running on them can make use of their combined computing resources.
With this type of hosting, your Virtual Private Server isn’t one of several
on a single server. Rather, it is one of hundreds all sharing a giant pool
of computing resources.
Typically, hosting companies try to keep the average level of resource
use well within the limits of the actual amount of computing power on-
hand. This might be as low as 50%. If there is a sudden increase is use
because one site has a spike in traffic, overall usage spikes but stays
within what the system as a whole can handle.
This works well for sites as they grow over time, also. The hosting
company adds more computing resources, or reorganizes how the virtual
machines are deployed on the system, in order to maintain optimum
performance as each site’s usage profile evolves.
Another benefit to scalable cloud hosting is that you usually only pay for
what you actually use. This is especially good for businesses that don’t
have the money to pay for high-end web hosting in the beginning, but
will eventually need the bandwidth if the business becomes successful.
One of the other neat features of some cloud-based VPS plans is that you
can actually have multiple virtual servers tied into one single account.
This is good for people who need a multi-stage development and
deployment structure, with a server each for dev, test, and production.
The thing to watch for with cloud-based or scalable hosting is that
“cloud” barely has any legal or technical meaning, and “scalable” is
equally ambiguous. Each hosting company has wildly different plans
under this umbrella of related terms, so be sure to read the actual
features you are purchasing, as well as reviews from real users.
Managed Hosting
If you need the bandwidth and power of a VPS or Dedicated Server, but
don’t have the technical skills (or the inclination) to do serious server
administration, you can get a managed hosting plan.
Managed hosting is a term that covers a lot of different types of plans,
but what they all have in common is that the hosting company provides
some sort of proactive technical support. This might be as simple as pre-
installing software and helping with initial configuration, to ongoing
monitoring and upgrading.
With some managed hosting plans, you have direct access to a VPS or a
dedicated server, and the hosting company provides support in addition
to that core hosting service. This gives you the flexibility to do what you
want or need to do, but without needing to know everything about server
administration.
Other managed hosting plans are geared toward specific applications
like WordPress, and your interaction with them is limited to the one
installation. The entire environment has been configured to provide the
best experience with one application, and there isn’t really anything else
for you to do. This is great if that’s the application you need, but it
doesn’t give you much flexibility.
Specialty Hosting
The hosting plans covered above account for the majority of offerings
from commercial hosting providers. The range of features, bandwidth,
and computing power available in one of these “conventional” hosting
plans will suit the needs of almost all people looking for web hosting
plans.
Just for the sake of completeness, it is worth noting that there are a
number of specialty hosting providers which specific hosting features
and support for various technology needs. Most of these are platform
specific, such as hosting geared to a particular language, database tool,
or framework. Others provide customized tool for certain development
methodologies.
The best advice is to not worry about these things at this point. If you are
setting up a website or blog for yourself, your business, or your
organization, it is highly unlikely that you will need some kind of
specialty hosting environment.
If you aren’t sure about your particular situation, you can use
our Compare Features Tool to see which hosts support the technology
you need.
How to know what kind of hosting you need
Shared hosting is a good fit for personal blogs, websites for small to
medium sized organizations like clubs and churches, and small non-tech
business. It it probably not appropriate for a business that relies
exclusively on its website for revenue, or for a large organization with a
lot of traffic. Also, any type of serious custom develop is usually not a
good fit with shared hosting.
VPS hosting is the right choice for most medium to large organization,
online stores, or major blogs. Depending on the relative size of future
traffic, you may need a “scalable” VPS solution that will be able to
handle large amounts of traffic. If you’re trying to start an online
business or launch a website for a well known brand, VPS hosting
should probably be where you start looking.
A dedicated server plan provides few real benefits over a VPS plan, and
can sometimes be more difficult to manage. This is really only a
reasonable choice if you have a server administration talent in your
organization and a compelling reason to run your applications without a
virtualization layer.
Summary
There is a lot of variety in available web hosting plans, but they all fall
into one of three categories:
Shared hosting
VPS hosting
Dedicated server hosting
Shared hosting is very cheap, but not very powerful. It is good for small
projects on a budget.
Dedicated hosting is very expensive and complicated. If you don’t know
whether you need it, you probably don’t need it.
VPS hosting, which is often “cloud based” or “scalable,” is the right
default choice for most serious business customers.
Both VPS and dedicated server plans are available in “managed hosting”
plans, which may be the right fit for you if you need the power and
flexibility of a complete server but don’t have the skills or resources in
your organization to manage the server yourself.
Once you have decided which type of hosting is right for you, you can
use our Hosting Features Comparison tool to compare your various
options.
Chapter 3: What are you buying when you buy web hosting?
Web hosting is an intangible service. You can’t really see it or touch it.
Because of that, its easy to think that all web hosting plans are the same,
or that web hosting isn’t worth paying for.
Extremely cheap hosting companies rely on this intangibleness to
suggest you only need to pay a few dollars a month, and that more
expensive plans are not worthwhile. At the same time, highly overpriced
hosting companies rely on it to sell otherwise normal hosting plans at
exorbitant rates, using marketing to make similar services seem vastly
different.
In order to make the most of your web hosting, and understand the
various pricing schemes available, it’s helpful to know what you are
actually buying when you buy web hosting, and what the company is
spending your fees on.
Servers
Though you will never see it, one of the biggest expenses of web hosting
is the physical equipment, the servers themselves. These are very fast
and powerful rack-mounted computers.
Of the many things that premium web hosting companies can do to
improve their service, using better (and more expensive) equipment is
one of the most impactful. Faster equipment mean faster website load
times, which is good for you and for your website visitors.
Data Centers
Servers have to sit somewhere, so an included expense is the physical
building where a server is located. These are usually very large buildings
housing hundreds or thousands of servers.
These buildings, and the equipment in them, have to be cooled,
maintained, and guarded. Datacenters use a lot of electricity, and they
have to be located somewhere that very high speed, high bandwidth
internet access is available.
Software
While much of the software used in web hosting is Open Source (like all
four elements of the LAMP stack), not all of it is. Notably, the most
popular control panel available for web hosting accounting management
(CPanel) is proprietary software that must be licensed and paid for.
If you need a Windows hosting plan, most of the software on the server
is proprietary, which is why Windows hosting is usually much more
expensive than Linux hosting. This is why you should only use
Windows hosting if you have a very specific need for that platform.
(Most people do not.)
Internet Connection
Web hosting companies are not internet service providers — they have
to purchase internet connectivity just like you do, and run their
connections over someone else’s cables.
Actually, it’s worse (more expensive) than your own internet service
because web hosting data centers need speed and bandwidth at orders of
magnitude higher than you have in your home or business. They are
running hundreds or thousands (or hundreds of thousands) of servers,
each one requiring internet connectivity at least as fast as your home or
workplace service.
Support
If you want to call someone, or get a prompt answer when you email,
you’re going to have to use a hosting company that provides at least
some level of support.
Support might come in the form of FAQs, knowledge base articles,
detailed guides, phone support, email support, or a help desk ticketing
system. Proactive server management can be thought of as a form of
support.
As with all things, you can expect that a more comprehensive support
program is going to cost more than an otherwise equal hosting package
without a support plan.
Business Overhead
It is easy to look around at available hosting plans and pick the cheapest
one, assuming they’re all about the same. The other common option is to
pick the most expensive one because it must be the best.
Neither of these is a good way to shop for a web hosting plan.
A better way is to think through what you need from your web hosting
company and what type of web hosting is required, and then compare
several plans that fit your minimal requirements. You should also read
reviews.
Once you’ve narrowed it down to the hosts that fit your needs, and
eliminated companies with a lot of bad reviews or outrageous pricing,
you’ll usually be left with a small handful of hosting plans at very
similar price points.
Summary
Price is not always a good indicator of quality. There are plenty of very
decent, low priced web hosting companies. However, if you need
something more than “very decent” you are going to have to pay more
for it. Premium web hosting — with fast processors, better connectivity,
lower downtime, and a higher level of support — costs more to provide,
and so it naturally costs more to purchase.
Rather than shopping based on price, it is better to begin by looking for
which features you need and finding hosting companies that provide
them.
Chapter 4: Features to Look For in Web Hosting
Speed
Bandwidth
Storage
Scalability
The problem with starting a new website is that you don’t really know
what your specific needs are going to be in the future. You can make
some guesses about how much bandwidth and storage you’ll need, but
those are usually only guesses.
For this reason, one of the more important things to look at when getting
web hosting is: how easy is it to upgrade.
If you start with a shared hosting plan, expecting to move up to VPS
when traffic reaches a certain point, will your web host be able to do
that? Without creating a break in service?
With VPS hosting, do you pay by the penny as usage goes up, or is there
a hard limit followed by massive overage charges? Will your host be
able to keep up if your site makes it to the first page of reddit or
slashdot?
It’s important that your web hosting account is able to handle both slow
and steady growth (through a reasonable upgrade path) and also sudden
spikes in traffic.
Even if you only plan to use a small, shared hosting account, look at the
larger VPS plans from the same host. If the shared plan costs $3/mo, but
the upgrade to VPS takes you to something really unmanageable, you
might be better off paying an extra couple of dollars per month in order
to have a more appropriate upgrade option later on. Also, it isn’t a good
idea to choose a web hosting company that only has shared hosting
plans.
Technology
Access
Almost all web hosting companies provide a control panel for managing
your hosting account. But not all of them make it easy to access your
account in other ways.
At the bare minimum, you want to be able to have FTP access to your
files. SSH (secure shell) access, which gives you a command line
interface to the server, is a good thing to have also, even if you don’t
plan to use it (you never know).
You should also find out if you can install additional programs on your
server, and how difficult that is. This might not be an issue for you
(maybe you’ll never use anything except WordPress forever), but it is
good to know ahead of time, especially if you even think you might
want to run other apps.
Support
Unless you are truly just running a personal blog and don’t care if it goes
down, make sure you find a hosting company with a good customer
support plan.
There are always problems. Even with the best web hosting company
and the most straightforward website, there will always be issues of one
sort or another. Technology is just too complicated for that not to be the
case. You want to make sure you have a hosting company that will help
you deal with the problems when they come up.
I wouldn’t sign up for hosting unless the company had a 24/7 phone line
I could call. Your personal requirements might be less strict, but think
about what they might be. If you have an unexpected outage at 3am, do
you want to have to wait until business hours in Salt Lake City before
you can talk to someone?
Concerning customer support, you should definitely read reviews in
our customer review section. People have had wonderful experiences
with the support staff of various hosting companies… and also not so
wonderful experiences. Reading reviews will help you understand what
kind of experience you might have.
Chapter 5: How a Web Hosting Server Works
When it comes down to it, we’re talking about something not that
different than your personal desktop or laptop computer. Servers are a
little bigger, a lot more powerful, and don’t usually have their own
monitors and keyboards, but at heart they are just like the computers you
use everyday.
Besides being a lot more powerful, the computers used to run websites
have very fast connections to the internet, so that a lot of visitors can
access the server at the same time.
Web server
Most (not all, but most) websites today are dynamic in some way.
Thinking back to the database and the web server in the last two
sections, it’s clear that there needs to be some software that fetches
content from the database and sends it to the web server. This is what
applications likeContent Management Systems (CMS) are all about.
Whether its a simple blogging engine, a complex CMS, an ecommerce
site, or project management system (or anything else), websites with
interactive features and dynamic content are computer programs, and
they have to be written in a programming language. You don’t have to
know the language to use the program, but your web hosting server
needs to know it.
The most popular language for dynamic web applications is PHP, and
you will find that the vast majority of web hosts support this language. If
you need to use an application (or develop an application) in another
language (Ruby and Python are both popular) make sure that you find a
web hosting company that supports the language you need.
LAMP Stack
Modules
If you are doing anything other than serving static files, you also need:
Database
Programming language
The most common choices for these four items are the LAMP
stack: Linux (operating system),Apache (web
server), MySQL (database), PHP (programming language).
Be sure that the web hosting provider you choose supports the
technologies required by the applications you plan to use.
Chapter 6: WordPress and Hosting
Most shared hosting companies are optimized for installing and running
WordPress, and large percentage of WordPress-powered websites are
hosted with shared hosting plans.
From a basic technical standpoint concerning requirements and set up,
shared hosting is perfectly fine. In fact, WordPress itself recommends a
shared hosting provider (Bluehost) as their number one recommended
hosting provider.
There’s a problem with this though — shared hosting plans are usually
not a good fit for high-traffic sites. This is especially the case with a
dynamic CMS like WordPress. Every page view requires a database
query and interpretation of one or more PHP scripts. When the traffic
spikes, this can quickly overload your shared hosting account’s capacity,
especially if you are running a lot of plugins or a poorly designed theme.
For this reason, we recommend shared hosting as a good option only for
personal blogs and small websites.
If you are running a serious business website with a lot of traffic, you
night be a good candidate for a managed hosting plan. These plans bring
a level of service beyond simply having better access to technology
(though they often come with that as well).
Managed WordPress hosting can cover a number of value-added support
services, such as making sure your website software stays up to date and
secure. Automated backups, downtime monitoring, advanced analytics,
and proactive security measures are all features commonly found in
managed WordPress hosting. Some managed hosting plans even include
their own distributions of WordPress with special plugins and packages
designed to increase performance, security, or user experience.
WordPress is built with a strong DIY (do it yourself) mentality, and is
relatively easy to use for beginners, compared to other options available.
Managed WordPress hosting isn’t a requirement by any means, and the
advantages it provides can usually be achieved by interested individuals.
What managed WordPress hosting really offers you is time. You could
easily learn to take care of things yourself, and do the work yourself. But
it may make better business sense to simply pay a little more to a hosting
company and let them take care of things for you.
Keep your core WordPress install and plugins upgraded to their latest
versions.
This should be old news by now, but way too many people do not
properly back up their WordPress content or theme files. Things go
wrong, sometimes — it’s best to have things backed up.
Also, if you are properly and securely backed-up, you can stop worrying
about updates potentially messing up your site. If something does go
wrong, you can just roll things back.
(WordPress itself reminds you to back up your site before updating
things, but so many people just skip right past those warnings.)
Just because WordPress allows you to upload and embed videos doesn’t
mean you should.
Videos use up a lot of storage space and a lot of bandwidth, so you will
quickly max out the capabilities of your hosting plan if you start
uploading videos on a regular basis.
Beyond that, do you really want to convert your video to different sizes
and resolutions so that it works equally well on different screen sizes
and with different connection speeds? Now you’re talking about extra
work (to produce different versions) and storing all those different
versions in your hosting account.
If you want your videos to be available publicly, host them on YouTube,
and copy in the embed code they provide. If you need your videos to be
private (for example, if they are behind a paywall on your site), Vimeo
Pro offers great video hosting for this purpose.
Hosting your videos at YouTube also provides another point of
discovery, another place that can lead people to find you who otherwise
wouldn’t know about your site.
Chapter 7: Cloud Computing
What will you learn in this chapter?
Your boss has read some article in a magazine about how “Cloud
Computing” is the next big thing. Now you’re supposed to figure out
what that means and how to do it. How can you “take adavantage” of
this cloud computing trend?
You can either engage in cloud computing as a producer or a consumer,
or both.
It is often said that in a gold rush, the people who sell shovels make
more money than the people who dig for gold.
This is true in reference to “the Cloud” as well — people who provide
some sort of cloud service are the biggest winners, and the more
fundamental the service, the larger the reward.
Providing IaaS or PaaS is a bit outside the realm of this guide and most
people reading it, but SaaS (software as a service) may not be.
If you sell software, it may be possible to re-imagine your application as
a SaaS offering. Rather than provide applications that clients have to run
on their own computers and servers, you may be able to provide access
to software through a web browser or web-connected desktop
application.
Consumer of Cloud Services
Cloud Hosting
As you almost certainly know, email addresses take the following form:
name@example.com
Everything before the @ sign is the local name, and everything after it is
the domain name.
It is a very bad practice, and unfortunately much too common, for small
organizations and sole practitioners to use a commercial email service
with a domain name like @gmail.com or@aol.com. This is a bad
practice because it looks unprofessional, amateurish.
It’s a very minor point, but it has a big impact on the way your clients
and potential customers think about you.
In an organization, such as a small business or (more commonly) a small
non-profit, the too-common practice of using personal email addresses
can introduce legal and ethical problems as well, because of the
inevitable mixing and confusion between personal and professional
communication. Also, email addresses controlled by the organization
can be turned off, blocked, forwarded to another address, or taken over
by another user.
Using email requires two things: an email server and an email client.
The email server is a piece of software that runs on the server
(computer) and is constantly connected to the internet. It receives and
processes any mail sent to it, and sends any mail you tell it to send.
The email client is the app you use to view your mail. This might be an
app on your phone, something you view in a web browser, or a desktop
application like Microsoft Outlook. The client checks the mail server for
new messages, and stores them for viewing. It provides an interface for
reading and writing messages. It sends outgoing messages to the server,
which sends them to their intended recipients.
The server and the client are two different pieces of software, and they
communicate using standardized protocols (POP and IMAP; see below).
This means that the choice of server and choice of client are independent
of each other.
People get confused about this all the time. One of the most often-heard
reasons people have for not wanting to switch from their personal email
addresses to organization-controlled email addresses is that they don’t
want to have to change how they read and write email. They use
Outlook, or Apple’s Email, and they think they will have to change. This
is not the case.
Most email clients can connect to most email servers with no problem.
Even better, most email clients can connect to multiple email servers and
work with multiple email accounts at the same time. This means that
someone who is using (for example) Outlook on their computer to check
their personal email account can set it up to check their professional
email as well.
If you are running your email through the email server on your web
hosting account, you have a few different options about how to access it.
The “traditional” way is to use an email client application on your own
computer. This could be Outlook, Apple Mail, the mail client on your
phone, or another similar program.
Webmail is another option, provided by most web hosts. The client
application runs in your web browser and you access your email by
logging into your hosting account and then opening the Webmail page.
The two most popular webmail client applications are Squirrel Mail and
RoundCube. If you do not want to run a local client app, you should
check to see if your hosting account provides access to one of these two
applications. (Many offer both.)
Setting up a Client
Other Options
Some commercial webmail providers, like Gmail, will allow you to use
your webmail account as a client for another email address. This is a
good solution for people who want to add their domain-branded email
address into their current commercial personal email address inbox, and
check everything from the same place.
Another option is to outsource email altogether. Instead of running email
through the email server associated with your hosting account, you can
set up your DNS record to work with a commercial email provider (like
Google Apps, for example). With this setup, you get all the features and
user experience of the commercial email provider, with your own
domain name.
Finally, a very simple solution is to set up an email forwarder that sends
email to your branded email address on to whatever personal email
address you already have. This is a good solution for personal bloggers
and very small one-person businesses. The downside is that you will
always be replying from your personal email address.
Application Email
Summary
Business and organizations should use domain-branded email, and not
personal email addresses, for conducting business communication.
Email is sent to and received from the internet by a software application
called a mail server. The user reads and writes email from an application
called a mail client. The choice of each is independent of the choice of
the other.
Options for accessing email include local clients, webmail clients, and
using a commercial account as a client. Alternatively, you can outsource
it completely, associating your branded domain with a commercial email
provider.
Two side issues concerning email are application email and marketing
email.
Application email, or transactional email, is email sent from your site’s
application code, related to the functioning of the site itself. This is not
usually connected with your email server. Most of the time, you will not
need to worry or think about this kind of email — it just happens. If you
are sending a very large amount of it, you may want to look into
outsourced transactional email solutions.
Marketing email, such as newsletters sent to people who have signed up
to receive them, is subject to very strict laws as well as account Terms of
Service conditions. For this reason, a commercial provider of email
marketing services is usually the best option.
Protip: Use first and last names
Buying on Price
All web hosting is basically the same, so buy the cheapest thing
you can find.
Quality costs money so buy the most expensive hosting you can
afford.
The last one is especially troublesome, and seems to only come up with
shared hosting providers in the under-$5 range. They will make URL
transfer a complicated, multi-step process; they will provide no
instructions for unlocking or transferring domains anywhere in the help
files; they will require phone verification of cancellation; they will hide
buttons for dealing with transfer and cancellation under vaguely-named
menu labels; they will flood their FAQ and knowledge base with articles
about transferring to their service, to push “transfer away” articles down
the page in search engine results.
They say “you get what you pay for.” With discount web hosting you
often get a whole lot more on top of that.
Of course, on the other end of the spectrum is the “you’ll be so proud
that you could afford it” premium web hosting.
Sometimes this is deliberately over-priced for what it is — a hosting
company sells a fairly standard VPS plan and dresses it up with words
like “blazingly fast” and “white glove support” and charges twice as
much as a similar plan from another company.
More often, the problem is simply overselling. If you are running a
personal blog that will be read by a few hundred people, you probably
don’t need the Turbo-Charged Premium 3000X ClusterRack Edge
Server with Water-Cooled Multiplexing.
Exacerbating the marketing problem is the tendency of shoppers to
compare on price, and buy something in the middle. Part of the reason
for $2.50/month web hosting is that it makes the $5.50/month plan seem
like a reasonable mid-grade solution, rather than just another cheap
shared hosting plan.
A better approach is to figure out what type of hosting you need first
(see the chapter in this guide on Types of Web Hosting), and then look
for well-reviewed and highly-rated companies that offer that type of
plan.
If it comes down to two options that have very similar features and are
equally well-reviewed, then you can think about picking the cheaper one
to save a few dollars. But most of the time, once you get to the two or
three hosting companies and plans that will fit your needs, you’ll find
they are going to be priced very close to each other.
And if you really need to save a few dollars, use one of our coupons.