HTML 4.01: Every Web Developer Has To Know The Building Blocks of The Web
HTML 4.01: Every Web Developer Has To Know The Building Blocks of The Web
Every Web developer has to know the building blocks of the Web:
• HTML 4.01
• CSS
• XHTML
• XML and XSLT
• JavaScript
• ASP or PHP
• Managing data with SQL
HTML 4.01
HTML is the language of the Web, and every Web developer should have a basic understanding of it.
HTML 4.01 is an important Web standard, and very different from HTML 3.2.
When tags, like <font> and color attributes, were added to HTML 3.2, it started a developer's
nightmare. Development of web sites where font information must be added to every single Web page
is a long and expensive job.
With HTML 4.01, all formatting can be moved out of the HTML document, and into a separate style
sheet.
HTML 4.01 is also important because XHTML 1.0 is HTML 4.01 "reformulated" as an XML application.
Using HTML 4.01 in your pages makes the future upgrade from HTML to XHTML a very simple process.
Style sheets are normally saved in external files. External style sheets enable you to change the
appearance and layout of EVERY page in your Web site, just by editing a single document. If you have
ever tried changing something like the font or color of all the headings in all your HTML pages, you will
understand how CSS can save a lot of work!
XHTML
XHTML stands for Extensible HyperText Markup Language.
XHTML is a reformulation of HTML 4.01 in XML, and is supported in all major browsers.
XML is as a cross-platform, software-, and hardware-independent tool for storing and transmitting
information.
We believe that XML is as important to the Web as HTML was to the foundation of the Web, and that
XML will be the most common tool for all data manipulation and data transmission.
XSLT can also add HTML elements, rearrange and sort data, make decisions about which data to
display, and more.
To deliver more dynamic web content, you should teach yourself JavaScript.
To deliver more dynamic web content, you should teach yourself server-side scripting.
SQL is used to access and manipulate data in MySQL, SQL Server, MS Access, Oracle, Sybase, DB2,
and other database systems.
Knowledge of SQL is a must for anyone wanting to store or retrieve data from a database.
We will also see new browsers, like the browsers found in mobile devices. We will also see more use of
XML for transmitting data between servers, or between servers and browsers.
Be sure to make your point in the very first sentence of the page! After that, try to keep the user
occupied with short paragraphs, and new headers down the page.
Less is More
Keep the paragraphs as short as possible.
Use a lot of space! Pages overloaded with text will kill your audience.
If you have a lot to say, break your information into smaller chunks and place it on different pages!
Navigation
Create a consistent navigation structure that is used by all the pages in your Web site.
Don't use hyperlinks inside paragraphs, to send visitors to every page of your Web. This will destroy
the feeling of a consistent navigation structure.
If you must use hyperlinks, add them to the bottom of a paragraph, or to the menu.
Download Speed
Sometimes developers are not aware of the fact that some pages take a long time to download.
Most visitors will leave a Web page that takes more than 7 seconds to download.
Test your web pages over a low-speed modem connection. If your pages take a long time to
download, consider removing graphic or multimedia content.
Your visitors are your "customers". Often they will give you some valuable hints about what you could
have done better.
Provide a simple way to reach you, and you will get a lot of input from people with different skills and
knowledge.
Visitor's Monitor
Not everyone on the internet has the same monitor as you.
If you design a Web site to be displayed on a monitor with a 1024x768 resolution, visitors with lower
resolution monitors (like 800x600) might have problems reading your pages.
The most popular browsers today are Internet Explorer and Firefox.
One wise thing to do when designing Web pages is to use correct HTML (or XHTML). Strict and correct
coding will help a browser to display your pages correctly.
Be sure that your visitors have access to the software needed to view them.
They might try to read your pages with Braille or speech-based browsers. Always add text alternatives
for pictures and graphic elements.
When developers follow the Web standards, the development is simplified, since it is easier for a
developer to understand another's coding.
Using Web standards will help you to ensure that all browsers, will display your Web site properly,
without frequent and time-consuming rewrites.
Web pages that conforms to the standard are easier for search engines to access and index, easier to
convert to other formats, and easier to access with program code (like JavaScript and the DOM).
Tip: Make a habit of validating your pages with a validation service. Validation keeps your documents
up to the standards, and free for errors.
Accessibility
Accessibility is an important part of the HTML standard.
Web standards make it easier for people with disabilities to use the Web.
Blind people can use computers that read Web pages for them. People with poor sight can rearrange
and magnify standard Web pages. Simple Web standards like HTML 4 and CSS, will make your Web
pages much easier to understand by special devices.
W3C, founded in 1994, is an international consortium dedicated to "lead the Web to its full potential".
As developers, especially when creating educational Web sites, we can help them turn this dream into
reality.
ECMA is not an official standardization institute, but an association of companies that collaborate with
other official institutes like the International Organization for Standardization (ISO) and the European
Telecommunications Standards Institute (ETSI).
For Web developers, the most important standard is ECMAScript, the standardization of
JavaScript.
The World Wide Web Consortium (W3C) creates the WWW standards.
W3C's mission is to lead the Web to its full potential, which it does by developing
specifications, guidelines, software, and tools.
PHP Introduction
PHP is a server-side scripting language.
• HTML/XHTML
• JavaScript
What is PHP?
• PHP stands for PHP: Hypertext Preprocessor
• PHP is a server-side scripting language, like ASP
• PHP scripts are executed on the server
• PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic
ODBC, etc.)
• PHP is an open source software
• PHP is free to download and use
What is MySQL?
• MySQL is a database server
• MySQL is ideal for both small and large applications
• MySQL supports standard SQL
• MySQL compiles on a number of platforms
• MySQL is free to download and use
PHP + MySQL
• PHP combined with MySQL are cross-platform (you can develop in Windows and serve on a
Unix platform)
Why PHP?
• PHP runs on different platforms (Windows, Linux, Unix, etc.)
• PHP is compatible with almost all servers used today (Apache, IIS, etc.)
• PHP is FREE to download from the official PHP resource: www.php.net
• PHP is easy to learn and runs efficiently on the server side
Where to Start?
To get access to a web server with PHP support, you can:
• Install Apache (or IIS) on your own server, install PHP, and MySQL
• Or find a web hosting plan with PHP and MySQL support
What is HTML?
HTML is a language for describing web pages.
HTML Tags
HTML markup tags are usually called HTML tags
The purpose of a web browser (like Internet Explorer or Firefox) is to read HTML documents and
display them as web pages. The browser does not display the HTML tags, but uses the tags to
interpret the content of the page:
<html>
<body>
</body>
</html>
Example Explained
• The text between <html> and </html> describes the web page
• The text between <body> and </body> is the visible page content
• The text between <h1> and </h1> is displayed as a heading
• The text between <p> and </p> is displayed as a paragraph
What is CSS?
• CSS stands for Cascading Style Sheets
• Styles define how to display HTML elements
• Styles were added to HTML 4.0 to solve a problem
• External Style Sheets can save a lot of work
• External Style Sheets are stored in CSS files
CSS Demo
An HTML document can be displayed with different styles: See how it works
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
When tags like <font>, and color attributes were added to the HTML 3.2 specification, it started a
nightmare for web developers. Development of large web sites, where fonts and color information
were added to every single page, became a long and expensive process.
To solve this problem, the World Wide Web Consortium (W3C) created CSS.
In HTML 4.0, all formatting could be removed from the HTML document, and stored in a separate CSS
file.
Styles are normally saved in external .css files. External style sheets enable you to change the
appearance and layout of all the pages in a Web site, just by editing one single file!
CSS Syntax
A CSS rule has two main parts: a selector, and one or more declarations:
The property is the style attribute you want to change. Each property has a value.
CSS Example
CSS declarations always ends with a semicolon, and declaration groups are surrounded by curly
brackets:
p {color:red;text-align:center;}
To make the CSS more readable, you can put one declaration on each line, like this:
Example
p
{
color:red;
text-align:center;
}
Try it yourself »
CSS Comments
Comments are used to explain your code, and may help you when you edit the source code at a later
date. Comments are ignored by browsers.
A CSS comment begins with "/*", and ends with "*/", like this:
/*This is a comment*/
p
{
text-align:center;
/*This is another comment*/
color:black;
font-family:arial;
}
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css" />
</head>
An external style sheet can be written in any text editor. The file should not contain any html tags.
Your style sheet should be saved with a .css extension. An example of a style sheet file is shown
below:
hr {color:sienna;}
p {margin-left:20px;}
body {background-image:url("images/back40.gif");}
Do not leave spaces between the property value and the units! "margin-left:20 px" (instead of
"margin-left:20px") will work in IE, but not in Firefox or Opera.
Internal Style Sheet
An internal style sheet should be used when a single document has a unique style. You define internal
styles in the head section of an HTML page, by using the <style> tag, like this:
<head>
<style type="text/css">
hr {color:sienna;}
p {margin-left:20px;}
body {background-image:url("images/back40.gif");}
</style>
</head>
Inline Styles
An inline style loses many of the advantages of style sheets by mixing content with presentation. Use
this method sparingly!
To use inline styles you use the style attribute in the relevant tag. The style attribute can contain any
CSS property. The example shows how to change the color and the left margin of a paragraph:
For example, an external style sheet has these properties for the h3 selector:
h3
{
color:red;
text-align:left;
font-size:8pt;
}
And an internal style sheet has these properties for the h3 selector:
h3
{
text-align:right;
font-size:20pt;
}
If the page with the internal style sheet also links to the external style sheet the properties for h3 will
be:
color:red;
text-align:right;
font-size:20pt;
The color is inherited from the external style sheet and the text-alignment and the font-size is
replaced by the internal style sheet.
Multiple Styles Will Cascade into One
Styles can be specified:
Tip: Even multiple external style sheets can be referenced inside a single HTML document.
Cascading order
What style will be used when there is more than one style specified for an HTML element?
Generally speaking we can say that all the styles will "cascade" into a new "virtual" style sheet by the
following rules, where number four has the highest priority:
1. Browser default
2. External style sheet
3. Internal style sheet (in the head section)
4. Inline style (inside an HTML element)
So, an inline style (inside an HTML element) has the highest priority, which means that it will override
a style defined inside the <head> tag, or in an external style sheet, or in a browser (a default value).
Introduction to XML
XML was designed to transport and store data.
• HTML
• JavaScript
If you want to study these subjects first, find the tutorials on our Home page.
What is XML?
• XML stands for EXtensible Markup Language
• XML is a markup language much like HTML
• XML was designed to carry data, not to display data
• XML tags are not predefined. You must define your own tags
• XML is designed to be self-descriptive
• XML is a W3C Recommendation
• XML was designed to transport and store data, with focus on what data is
• HTML was designed to display data, with focus on how data looks
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
The note above is quite self descriptive. It has sender and receiver information, it also has a heading
and a message body.
But still, this XML document does not DO anything. It is just information wrapped in tags. Someone
must write a piece of software to send, receive or display it.
With XML You Invent Your Own 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.
The tags used in HTML are predefined. HTML documents can only use tags defined in the HTML
standard (like <p>, <h1>, etc.).
XML allows the author to define his/her own tags and his/her own document structure.
It is important to understand that XML is not a replacement for HTML. In most web applications, XML
is used to transport data, while HTML is used to format and display the data.
To read more about the XML activities at W3C, please read our W3C Tutorial.
XML is Everywhere
XML is now as important for the Web as HTML was to the foundation of the Web.
XML is the most common tool for data transmissions between all sorts of applications.
With XML, data can be stored in separate XML files. This way you can concentrate on using HTML for
layout and display, and be sure that changes in the underlying data will not require any changes to
the HTML.
With a few lines of JavaScript code, you can read an external XML file and update the data content of
your web page.
XML data is stored in plain text format. This provides a software- and hardware-independent way of
storing data.
This makes it much easier to create data that can be shared by different applications.
Exchanging data as XML greatly reduces this complexity, since the data can be read by different
incompatible applications.
XML data is stored in text format. This makes it easier to expand or upgrade to new operating
systems, new applications, or new browsers, without losing data.
With XML, your data can be available to all kinds of "reading machines" (Handheld computers, voice
machines, news feeds, etc), and make it more available for blind people, or people with other
disabilities.
• XHTML
• WSDL for describing available web services
• WAP and WML as markup languages for handheld devices
• RSS languages for news feeds
• RDF and OWL for describing resources and ontology
• SMIL for describing multimedia for the web
The future might give us word processors, spreadsheet applications and databases that can read each
other's data in XML format, without any conversion utilities in between.
<p>This is a paragraph
<p>This is another paragraph
In XML, it is illegal to omit the closing tag. All elements must have a closing tag:
<p>This is a paragraph</p>
<p>This is another paragraph</p>
Note: You might have noticed from the previous example that the XML declaration did not have a
closing tag. This is not an error. The declaration is not a part of the XML document itself, and it has no
closing tag.
Opening and closing tags must be written with the same case:
<Message>This is incorrect</message>
<message>This is correct</message>
Note: "Opening and closing tags" are often referred to as "Start and end tags". Use whatever you
prefer. It is exactly the same thing.
In the example above, "Properly nested" simply means that since the <i> element is opened inside
the <b> element, it must be closed inside the <b> element.
<root>
<child>
<subchild>.....</subchild>
</child>
</root>
Study the two XML documents below. The first one is incorrect, the second is correct:
<note date=12/11/2007>
<to>Tove</to>
<from>Jani</from>
</note>
<note date="12/11/2007">
<to>Tove</to>
<from>Jani</from>
</note>
The error in the first document is that the date attribute in the note element is not quoted.
Entity References
Some characters have a special meaning in XML.
If you place a character like "<" inside an XML element, it will generate an error because the parser
interprets it as the start of a new element.
To avoid this error, replace the "<" character with an entity reference:
Note: Only the characters "<" and "&" are strictly illegal in XML. The greater than character is legal,
but it is a good habit to replace it.
Comments in XML
The syntax for writing comments in XML is similar to that of HTML.
• HTML / XHTML
What is JavaScript?
• JavaScript was designed to add interactivity to HTML pages
• JavaScript is a scripting language
• A scripting language is a lightweight programming language
• JavaScript is usually embedded directly into HTML pages
• JavaScript is an interpreted language (means that scripts execute without preliminary
compilation)
• Everyone can use JavaScript without purchasing a license
Java and JavaScript are two completely different languages in both concept and design!
Java (developed by Sun Microsystems) is a powerful and much more complex programming language
- in the same category as C and C++.
JavaScript Where To
JavaScripts can be put in the body and in the head sections of an HTML page.
Put your functions in the head section, this way they are all in one place, and they do not interfere
with page content.
Example
<html>
<head>
<script type="text/javascript">
function message()
{
alert("This alert box was called with the onload event");
}
</script>
</head>
<body onload="message()">
</body>
</html>
Try it yourself »
Scripts in <body>
If you don't want your script to be placed inside a function, or if your script should write page content,
it should be placed in the body section.
Example
<html>
<head>
</head>
<body>
<script type="text/javascript">
document.write("This message is written by JavaScript");
</script>
</body>
</html>
Try it yourself »
Example
<html>
<head>
<script type="text/javascript">
function message()
{
alert("This alert box was called with the onload event");
}
</script>
</head>
<body onload="message()">
<script type="text/javascript">
document.write("This message is written by JavaScript");
</script>
</body>
</html>
Try it yourself »
To use the external script, point to the .js file in the "src" attribute of the <script> tag:
Example
<html>
<head>
<script type="text/javascript" src="xxx.js"></script>
</head>
<body>
</body>
</html>
Try it yourself »
Note: Remember to place the script exactly where you normally would write the script!
ASP Introduction
An ASP file can contain text, HTML tags and scripts. Scripts in an ASP file are
executed on the server.
• HTML / XHTML
• A scripting language like JavaScript or VBScript
If you want to study these subjects first, find the tutorials on our Home page.
What is ASP?
• ASP stands for Active Server Pages
• ASP is a Microsoft Technology
• ASP is a program that runs inside IIS
• IIS stands for Internet Information Services
• IIS comes as a free component with Windows 2000
• IIS is also a part of the Windows NT 4.0 Option Pack
• The Option Pack can be downloaded from Microsoft
• PWS is a smaller - but fully functional - version of IIS
• PWS can be found on your Windows 95/98 CD
ASP Compatibility
• To run IIS you must have Windows NT 4.0 or later
• To run PWS you must have Windows 95 or later
• ChiliASP is a technology that runs ASP without Windows OS
• InstantASP is another technology that runs ASP without Windows
Note: Because ASP scripts are executed on the server, the browser that displays the ASP file does
not need to support scripting at all!
Introduction to SQL
SQL is a standard language for accessing and manipulating databases.
What is SQL?
• SQL stands for Structured Query Language
• SQL lets you access and manipulate databases
• SQL is an ANSI (American National Standards Institute) standard
However, to be compliant with the ANSI standard, they all support at least the major commands (such
as SELECT, UPDATE, DELETE, INSERT, WHERE) in a similar manner.
Note: Most of the SQL database programs also have their own proprietary extensions in addition to
the SQL standard!
RDBMS
RDBMS stands for Relational Database Management System.
RDBMS is the basis for SQL, and for all modern database systems like MS SQL Server, IBM DB2,
Oracle, MySQL, and Microsoft Access.
SQL Syntax
Database Tables
A database most often contains one or more tables. Each table is identified by a name (e.g.
"Customers" or "Orders"). Tables contain records (rows) with data.
The table above contains three records (one for each person) and five columns (P_Id, LastName,
FirstName, Address, and City).
SQL Statements
Most of the actions you need to perform on a database are done with SQL statements.
The following SQL statement will select all the records in the "Persons" table:
SELECT * FROM Persons
Semicolon is the standard way to separate each SQL statement in database systems that allow more
than one SQL statement to be executed in the same call to the server.
We are using MS Access and SQL Server 2000 and we do not have to put a semicolon after each SQL
statement, but some database programs force you to use it.
The query and update commands form the DML part of SQL:
The DDL part of SQL permits database tables to be created or deleted. It also define indexes (keys),
specify links between tables, and impose constraints between tables. The most important DDL
statements in SQL are: