HTML Uniform Resource Locators
HTML Links
When you click on a link in an HTML document like this: Last Page, an underlying <a> tag points to a place (an address) on the Web with an href attribute value like this: <a href=”lastpage.html”>Last page</a>.
The Last Page link in the example is a link that is relative to the Web site that you are browsing, and your browser will construct a full Web address like http”//www.rgcsm.org/html/ last page .htm to access the page.
Creating an Email Link
Building an attractive, useful Web page is only part of the job. You also need to give viewers a way to contact you.
In the digital age, Web users expect to have instant and easy email contact with you. To make a link to your email address, you’ll need to use the anchor tag again. You can separate you r email contact with the <HR> tag, which inserts a horizontal line. We’ve decided to have the email contact link centered on the page. Put it below the list, like this:
<CENTER>
<HR>
<a href=mailto:comments@builder.com”>Drop us a line! </a>
</CENTER>
Uniform Resource Locators
Something called a Uniform Resource Locator (URL) is used to address a document (or other dada) on the World Wide Web. A full Web address like this: http://www.rgcsm.org/jtml/lastpage. htm follows these syntax rules:
scheme://host.domain:port/path/filename
The scheme is defining the type of Internet service. The most common type is http.
The domain is defining the Internet domain name like rgcsm.org.
The host is defining the domain host. If omitted, the default host for http is www.
The: port is defining the port number at the host. The port number is normally omitted. The default port number for http is 80.
The path is defining a path (a sub directory) at the server. If the path is normally omitted, the resource (the document) must be located at the root directory of the Web site.
The filename is defining the name of a document. The default filename might be default.asp, or index.html or something else depending on the settings of the Web server.
URL Schemes
Some examples of the most common schemes can be found below:
Schemes – Access
file – a file on your local PC
ftp – a file on an FTP server
http – a file on a World Wide Web server
gopher – a file on a Gopher server
news – a Usenet newsgroup
telnet – a Telnet connection
WAIS – a file on a WAIS server
Accessing a Newsgroup
The following HTML code:
<a href=news:alt.html>HTML Newsgroup</a>
Creates a link to a newsgroup like this HTML Newsgroup.
Downloading with FTP
The following HTML code:
<a href=ftp://www.rgcsm.org/ftp/WinZip.exe>Download WinZip</a>
Creates a link to download a file like this: Download WinZip.
(The link doesn’t work. Don’t try it. It is just an example. W3C Schools doesn’t really have an ftp directory.)
Link to your Mail system
The following HTML code:
<a href=mailto:someone@rgcsm.com”>someone@rgcsm. Com</a>
Creates a link to your own mail system like this:
HTML Scripts
Add scripts to HTML pages to make them more dynamic and interactive.
Insert a Script into HTML Page
A script in HTML is defined with the <script> tag. Note that you will have to use the type attribute to specify the scripting language. <html>
<head>
</head>
<body>
<script type=”text/javascript”>
document. write (“Hello World!”)
</script>
</body>
</html>
The script above will produce this output:
Hello World!
How to Handle Older Browsers
A browser that does not recognize the <script> tag at all, will display the <script> tag’s content as text on the page. To prevent the browser from doing this, you should hide the script in comment tags. An old browser (that does not recognize the <script> tag) will ignore the comment and it will not write the tag’s content on the page, while a new browser will understand that the script should be executed, even if it is surrounded by comment tags.
Example
JavaScript:
<script type=”text/javascript”>
<!—
document.write (“Hello World!”)
//– >
</script>
VBScript:
<script type=”text/vbscript”>
<!–
document.write(“Hello World!”)
‘– >
</script>
The <noscript> Tag
In addition to hiding the script inside a comment, you can also add a <noscript> tag.
The <noscript> tag is used to define an alternate text if a script is NOT executed. This tag is used for browsers that recognize the <script> tag, but do not support the scrip0t inside, so these browsers will display the text inside the <noscript> tag instead. However, if a browser supports the script inside the <script> tag it will ignore the <noscript> tag.
Example
JavaScript:
<script type=”text/javascript”>
<!—
document.write(“Hello World!”)
//– >
</script>
<noscript>Your browser does not support Java Script! </noscript>
VBScript:
<script type=”text/vbscript”>
<!–
document.write(“Hello World!”)
‘– >
</script>
<noscript>Your browser does not support VBScript! </noscript>
Script Tags
Tag | Description |
<script> | Defines a script |
<noscript> | Defines an alternate text if the scriptis not executed |
<object> | Defines an embedded object |
<param> | Defines run=time settings (parameters)for an object |
<applet> | Deprecated. Use <object> instead |
The Meta Element
As we explained in the previous chapter, the head element contains general information (meta-information) about a document.
HTML also includes a meta element that goes inside the head element. The purpose of the meta element is to provide meta-information about the document.
Most often the meta element is used to provide information that is relevant to browsers or search engines like describing the content of your document.
Note: W3C states that “Some users agents support the use ofMETAto refresh the current page after a specified number of seconds, with the option of replacing it by a different URL. Authors should not use this technique to forward users to different pages, as this makes the page inaccessible to some users. Instead, automatic page forwarding should be done using server-side redirects”
Keywords for Search Engines
Some search engines on the WWW will use the name and content attributes of the meta tag to index your pages.
This meta element defines a description of your page:
<meta name=”description” content=”Free Web tutorials on HTML, CSS, XML, and XHTML”>
This meta element defines keywords for your page:
<meta name=”keywords” content=”HTML, DHTML, CSS, XML, XHTML, JavaScript, VBScript”>
The intention of the name and content attributes is to describe the content of a page.
However, since too many webmasters have used meta tags for spamming, like repeating keywords to give pages a higher ranking, some search engines have stopped using them entirely.
Unknown Meta Attributes
Sometimes you will see meta attributes that are unknown to you like this:
<meta name=”security “content=”low”>
Then you just have to accept that this is something unique to site or to the author of the site, and that it has probably no relevance to you.
HTML 4.0 Standard Attributes
HTML tags can have attributes. The special attributes for each tag are listed under each tag description. The attributes listed here are the core and language attributes that are standard for all tags (with a few exceptions):
Core Attributes
Not valid in base, head, html, meta, param, script, style, and title elements.
Attribute | Value | Description |
class | class_rule or style_rule | The class of the element |
id | id_name | A unique id for the element |
style | style_definition | An inline style definition |
title | tooltip_text | A text to display in a tool tip |
Language Attributes
Not valid in base, br, frame, frameset, hr, iframe, param, and script elements
Attribute | Value | Description |
dir | ltr | rtl | Sets the text direction |
lang | language_code | Sets the language code |
Keyboard Attributes
Attribute | Value | Description |
accesskey | character | Sets a keyboardshortcut to access
an element |
tabindex | number | Sets the tab orderof an element |
HTML 4.0 Event Attributes
New to HTML 4.0 is the ability to let HTML event trigger actions in the browser, like starting a JavaScript when a user clicks on an HTML element. Below is a list of attributes that can be inserted into HTML tags to define event actions.
Window Events
Only valid in body and frameset elements.
Attribute | value | Description |
onload | script | Script to be run when adocument loads |
onunload | script | Script to be run when adocument unloads |
Form Element Events
Only valid in form elements.
Attribute | Value | Description |
onchange | script | Script to be run when theelement changes |
onsubmit | script | Script to be run when theform is submitted |
onresel | script | Script to be run when theform is resel |
onselect | script | Script to be run when theelement is selected |
onblur | script | Script to be run when theelement loses focus |
onfocus | script | Script to be run when theelement gets focus |
Keyboard Events
Not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, and title elements.
Attribute Value Description
onkeydown script what to do when key is pressed
onkeypress script what to do when key is pressed and released
onkeyup script what to do when key is released
Morse Events
Not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, and title elements.
Attribute | Value | Description |
onclick | script | What to do on a mouse click |
ondblclick | script | What to do on a mousedouble-click |
onmousedown | script | What to do on a mousebutton is pressed |
onmousemove | script | What to do on a mousepointer moves |
onmousout | script | What to do on a mousepointer moves out of an
element |
onmousover | script | What to do on a mousepointer moves over an element |
onmouseup | script | What to do on a mousebutton is released |
Web Publishing
Your First Step: A Personal Web Server
- If you want other people to view your pages, you must publish them.
- To publish your work, you have to copy your files to a web server.
- Your own PC can act as a web server if it is connected to a network.
- If you are running Windows 98, you can use the PWS (personal Web Server).
- PWS is hiding in the PWS folder in your Windows CD.
Personal Web Server (PWS)
PWS turns any Windows computer into a Web server. PWS is easy to install and ideal for developing and testing Web application. PWS has been optimized for working use, but has all the requirements of a full Web server. It also runs Active Server Pages (ASP) just like its larger brother IIS.
How to Install a Personal Web Server (PWS)
Browser your Window installation to see if you have installed PWS. If not, install PWS from the PWS directory on your Window CD. Follow the instructions and get your personal Web Server up and running.
Note: Microsoft Windows XP Home Edition does not come with the option to turn your computer into a PWS! Internet Information Server(IIS)
Windows 2000’s built-in Web server IIS, makes it easy to build large applications for the Web. Both PWS and IIS include ASP, a server- side scripting standard that can be used to create dynamic, and interactive Web applications, IIS is also available for Windows NT.
Your Next Step: A Professional Web Server
- If you do not want to use PWS or IIS, you must upload your files to a public server.
- Most Internet Service Providers (ISP’s) will offer to host your web pages.
- If your employer has an Internet Server, you can ask him to host your Web site.
- If you are really serious about this, you should install your own Internet Server.