This document was uploaded by user and they confirmed that they have the permission to share
it. If you are author or own the copyright of this book, please report to us by using this DMCA
report form. Report DMCA
Home | HTML | ASP | JAVA | VB | OFFICE 2000 | .NET | C#
HTML INTRODUCTION TO MARKUP LANGUAGE What is programming language? A language is a system of communication. With our natural language such as English, we communicate to one another our ideas and emotions. Similarly, a computer language is a means of communication used to communicate between people and the computer. With the help of a computer language, a programmer tells a computer what he wants it to do. Unlike natural language, most computer languages use a very limited or restricted vocabulary. This is mainly because a programming language by its very nature and purpose does not need to say too much. Classification of programming language Normally programming language can be classified as a) PROCEDURAL PROGRAMMING LANGUAGE b) OBJECT ORIENTED PROGRAMMING LANGUAGE • Procedural programming language Procedure is nothing but a sequence of statements, which perform some specific task and it should return some value after performing that function. Some languages follow or work with procedures like BASIC, PASCAL, and C etc. • Object oriented programming language Before discussing the object-oriented approach, first we have to define the object. For now, we will consider the object to be a package of information together with the operation that can be performed on that information. In other words, an object supports data abstraction, and can be considered as an entity, which encapsulates the object data, and provide the user with a set of predefined operations to manipulate and access the object data. The object data can only be accessed by the operations defined on the object. Some programming languages like C++, Java etc follows this Object Oriented approach and these languages are called Object Oriented Programming Languages, What is Markup Language?
A markup language is a set of conventions for the linear encoding of information structures. There are nonlinear ways to structure information, most notably relational databases. Database schemas and markup languages do the same job. They express the structure of data. So a markup language is only useful if you know what it means. INTRODUCTION TO HTML What is html?
Hyper Text Markup Language HTML stands for Hyper Text Markup Language. Hyper Text Markup Language
Hyper You may have heard the expression "hyper" in describing someone. In simplest terms, it means active, kind of "all over the place". The word "Hyper" as part of HTML is similar in context. It simply means that when you are on the Internet using a browser such as Netscape Navigator or Internet Explorer, you can in fact; go "all over the place". In browsing through the World Wide Web (WWW), if you see something you like, you can go immediately to it. There is no set order to do things in. Hyper is the opposite of "linear". Linear means that there is a certain order you must follow such as "you must do this before you can do that". Programming languages such as BASIC and FORTRAN are linear. HTML does not hold to that and allows you to jump to any page on the WWW and at any time. Thus the word HYPER refers to the idea that the text in HTML is not linear.
Text We are working with text only files.
Markup "Markup" comes from the fact that in order to create web pages, we will be typing in the text and then "marking up" the text.
Language "Language" means that we are using a language with all its syntax. Note that HTML is not a programming language such as BASIC or FORTRAN. These are
linear programming languages and are based on a whole different set of rules and are far more complicated to learn. The HTML language is easy to learn.
History Of HTML After companies started using computers for document processing, it soon became obvious that a storage format should contain not only formatting codes interpreted by computer itself, but also descriptive, human-legible information about the nature and role of every element in a document. The first working system that used these concepts was the Generalized Markup Language (GML) developed by Charles Goldfarb, Edward Mosher, and Raymond Lorie at IBM. This system was the direct predecessor of SGML. SGML stands for Standard Generalized Markup Language. SGML is a generalpurpose tool for developing documents of any kind. It originated in the 1960s. It was developed to overcome problems while moving documents across hardware platforms and operating systems. As SGML is used for defining and creating descriptive markup languages and hence it is known as Metalanguage. SGML is platform independent, requiring only a computer and the appropriate software to analyze the documents to make sense of the data. Before HTML, a document’s author didn’t have to care how the document would appear on someone’s monitor. Different versions of HTML HTML Level 0 HTML was at level 0 in its first implementation in 1990. At that time, the means of communication over the Internet included email, Ftp (File Transfer Protocol), and Telnet, all using TCP/IP (Transmission Control Protocol/Internet Protocol). Berners-Lee & his colleagues used SGML to implement HTML. HTML 1.0 The original version of HTML was HTML 1.0. It had very limited features, which greatly limited what you could do in designing your web pages. HTML+ & the advent of graphics Dave Raggett proposed another extension of HTML called HTML+, which incorporated graphical & display elements into HTML. For that reason HTML+ was able to advantage of graphics based browsers.
HTML 2.0 HTML 2.0 then arrived and included all the features of HTML 1.0 plus several new features for web page design. Until January 1997, HTML 2.0 was the standard in web page design. HTML 3.0 HTML 2.0 served its purpose very well, but many people designing web pages (called HTML authors or webmasters) wanted more control over their web pages and more ways to mark up their text and enhance the appearance of their websites. Netscape, the leading browser at that time, introduced new tags and attributes called the Netscape Extension Tags. Other browsers tried to duplicate them but Netscape did not fully specify their new tags and so these extension tags did not work in most other browsers. It led to considerable confusion and problems when HTML authors used these tags and attributes and then saw that they didn't work as expected in other browsers. At about that time, an HTML working group, led by Dave Raggett, introduced the HTML 3.0 draft, which included many new and useful enhancements to HTML. However, most browsers only implemented a few elements from this draft. The phrase "HTML 3.0 enhanced" quickly became popular on the web but it more often than not referred to documents containing browser specific tags (discussed below in "The Netscape Problem" section), instead of referring to documents adhering to the HTML 3.0 draft. This was one of the reasons why the draft was abandoned. HTML 3.0 is now an expired draft. Another reason why HTML 3.0 did not make it was because it was so "big". Future versions were now to be introduced in a more "modular" way so that browsers can implement them modular-by-modular or bit-by-bit. HTML 3.2 (WILBUR) As more browser-specific tags were introduced, it became obvious that a new standard was needed. For this reason, the Word Wide Web Consortium (W3C), founded in 1994 to develop common standards for the evolution of the WWW, drafted the WILBUR standard, which later became known as HTML 3.2. HTML 3.2 captures the recommended practice as of early 1996 and became the official standard in January 1997. Most, if not all, popular browsers in use today fully support HTML 3.2. HTML 4.0 (COUGAR) HTML 4.0 is the current version of HTML. In the early days it was code-named COUGAR. This version introduces new functionality, most of which comes from the expired HTML 3.0 drafts. This version became a recommendation in December 1997 and is now the official standard as of April 1998. Explorer has done a very good job in implementing the many features of HTML 4.0. Unfortunately, Netscape has not kept pace. The latest version of Netscape Communicator still does not recognize the many tags and attributes introduced with HTML 4.0. This means that a web page that involves HTML 4.0 specific tags will look great in Explorer, but can look disastrous in Netscape.
Why we use HTML? HTML allows the assignment of characteristics of text, such as font size, style and type. It also allows the creation of new structural elements such as objects and the definition of characteristics of those objects. • LANGUAGE is COMMON HTML was meant to be a common language that could be used to tie together information from widely different sources. • SIMPLE HTML was meant to be simple for both HTML authors and programmers to use. • PLATFORM INDEPENDENCE It is popular for its platform independence. HTML follows the general philosophy of the web, which is to “be conservative in what is produced and liberal in what is accepted”. This means that the servers try to maximize the correctness and conformance of the HTML output and the Web browsers strive to make sense out of what the server sends. Uniform Resource Locator (URL) Uniform Resource Locator (URL) is the primary naming scheme, which is used to identify Web resources that can either be HTML, documents or other services present in the Web. These Web resources are identified with special names called Uniform Resource Identifier (URI). The URL is the standard method used to identify any resource. Mostly it consists of Service, Hostname and Directory path. Service:// hostname: port/directory-path Service indicates the name of the protocol used to access data present on the other end of the link. Hostname indicates the domain name for the web server where the web page resides. In most cases specification of the port address is not required as the servers themselves have a default port address. Directory-path specifies the name of the HTML file. World Wide Web (WWW) The World Wide Web is a vast amorphous blob of text, images, audio and video scattered across networks and computers worldwide. Hence the name World Wide Web has came. It is shortly referred to as “Web” or “W3”. It is a software
invention, which aids users to explore the Internet facility. World Wide Web is a part of the Internet comprising of Web pages and Web sites. Web is a collection of files known as Web pages. These Web pages can contain hyperlinks to link other Web pages. A hyperlink can be any text or image which when clicked would display another web page. There may be one or more pages in the Home page, which is the initial Web page present in a Web site. Browsers A Web browser is a special type of parsing engine that evaluates the tags and content of an HTML file and displays it according to the capabilities and rules of the file’s own capabilities and platform. For example-a text-only browser displays the alternative text for an image, but a graphical browser displays the actual image. The major browser used to surf the Internet is, Microsoft Internet Explorer and another browser, which is the product of Sun Micro system is Netscape Navigator. Hardware Requirement MINIMUM
PREFERRED
a) 286PC
a) 133 MHz Pentium PC
b) 16MB of RAM
b) 32 MB of RAM
c) 500-MB Hard Disk
c) 1.2 GB Hard Disk
Software Requirement
• • Microsoft Windows 95 (Standard Installation), Windows NT, Unix, Linux etc. • • Microsoft Internet Explorer 3.0 or higher.
• • Netscape Navigator 3.0 or higher. • • Internet Connection (optional, it is applicable for live project) What do I need to begin designing a Home Page? •
•
You need a directory (also called a FOLDER)
You should set up a directory or folder to hold only your HTML files (also called documents) for the web pages you are designing. Work in that directory only. If you are doing all these lessons, you may also wish to set up a separate directory to hold all the examples for testing in your browser. You need some place to put your work.
•
•
You do not need to have your modem connected
You do not need to be connected by modem to your server. You can write and design your HTML pages off-line. If all you are doing is designing web pages, you have no need to go on the Internet. Besides, if you are paying by the hour, you don't want to pay any more than you have to. Also, if you have only one telephone line to your house and you are connected by phone, there is no need to tie up the line for hours at a time. How do you disconnect the modem? Well, in most cases, when you load the browser, a little window opens up to dial the server. Simply click CANCEL, and choose to work off-line. If you are using an old version of a browser and this method doesn't work, you may need to call on someone to help you. So remember, you do not need to be connected by modem to design your web pages. •
•
You need a browser
Netscape Navigator (also called Netscape Communicator) and Internet Explorer are among today's most popular browsers and there are different versions of each of these. Netscape, as of version 4.0, is called Netscape Communicator. Before version 4.0, it was called Netscape Navigator. There are other browsers also but they are not nearly as popular as Netscape and Explorer. Most likely you already have a browser or you wouldn't be reading this.
•
•
You need a word processor
You need a word processor such as WordPerfect or Microsoft Word or Microsoft Works. Better use NOTEPAD, which can be found in the ACCESSORIES directory (also know as the ACCESSORIES "GROUP"). In Windows 95, for example, NOTEPAD is found by choosing "START"à"PROGRAMS"à"ACCESSORIES"à”NOTEPAD”. Notepad is a simple "text editor" that loads almost instantly. A text editor is a very simple word processor. NOTEPAD also quickly loads any file and quickly saves the file. As we will see later in this lesson, there are other reasons as well for using a text editor such as NOTEPAD. Sometimes a web page can become so big that it will no longer fit into NOTEPAD. In this case, you will need to switch to another text editor or to your word processor to complete the page.
In summary, you basically: 1. 1. Do your work in a text editor such as NOTEPAD (typing in all the text and tags)
2. 2. Save your work in an HTML file using any appropriate name 3. 3. Load the HTML file into the browser to see how your web page looks and works 4. 4. Switch back to NOTEPAD to make any corrections, changes, etc. Naming your text only file You need to give your file (that is, your web page) a name. You not only have to give it a name but you also need to add a suffix to the name. THE NAME: If you are using an IBM or IBM compatible computer and not running Windows 95 or higher, your file name is limited to a maximum of 8 characters. Otherwise the name can be longer. THE SUFFIX: The suffix is an extension to the name and declares the kind of document that it is. In HTML, the suffix is either ". htm" or ".html". "Htm" or "html" tells the browser you are working with HTML files - that is, an HTML document. Saving your html file (or document) IF YOU ARE USING ONLY NOTEPAD or similar text editor: Simply type in a suitable file name (along with an extension) and click on "OK". Loading your html document into the browser Once you have saved your HTML file or document, you need to SWITCH over to your browser, which is running in the background. Once you activate your browser, choose File from the menu bar, and then choose Open ... or Open File ... or Open File in Browser ... (one of them should be in the File menu). You will then need to locate your file, click on the file name and then click the Okay button. Your HTML file will appear in the browser. You can only observe your file in the browser - you cannot edit in the browser. Once you have seen how your HTML file looks in the browser, you can then SWITCH back to NOTEPAD to continue working and editing. Note: (1) (1) If you want to LOAD a new HTML file into NOTEPAD, and the name does not show up in the correct directory in the dialog window, choose to show All Files (*.*) in the Files of type line and the name should then appear. Click on the name and then on the Open button. (2) (2) If you use a word processor other than NOTEPAD, you may first need to CLOSE the HTML file before it can be loaded into your browser. With NOTEPAD this is not necessary.
HTML ELEMENTS HTML comprises of three major elements that render a well-structured look for a document. • • Head • • Body • • Footer HTML tags HTML works in a very straightforward manner. You type in your text and your tags. To get large print, centered text, bold text, text in italics, indented sentences, colored text, etc., is nothing more than inserting tags around your text. These tags are more accurately called ELEMENTS and you should think of these elements as describing the meaning of the text they contain, rather than how the enclosed text should be displayed. This concept is called contentbased markup, as opposed to presentational markup. Because we don't want the tags (elements) to appear in the browser, we need a way to tell the browser that something is a tag - and this is easy to do. To tell the browser that something is a tag, you simply place "less than" and "greater than" symbols around them. The LESS THAN symbol is "<" and the GREATER THAN symbol is ">". These symbols are also called "Angle Brackets". Thus we have an opening angle bracket "<" and a closing angle bracket ">" around each tag. Correct use of tags We have "beginning" or "opening" tags (such as ) and we have "ending" or "closing" tags (such as ). Many elements consist of an opening tag and a closing tag. An element that has an opening and closing tag is referred to as a container element because anything contained between these tags are affected by the element. Closing Tags cannot be placed just anywhere. Use the "Last In = First Out" principle or "LIFO". That is, the "Last" tag "In" must be the "First" tag "Out". Another way of stating this is that the last tag activated must be the first tag terminated? An example of a correct sequence of tags is: statements In this example, is activated first, and then . Thus must be terminated first with followed by the termination of (). In other words, tags are closed in reverse order to the way they are opened. Thus the first tag opened must be the last tag closed. An example of an incorrect placement of tags is: statements In this example, the last tag opened () is not the first tag closed. That is, these tags overlap. must come before . Therefore this example does not satisfy the LIFO principle. Container tags cannot overlap each other. If you do not place tags properly, your web page simply won't work.
The following is another example of a correct use of tags: statements Classification of html tags A markup tag is defined by the markup element and an optional set of attributes. Tags are divided into two groups, non-empty and empty. There are mainly two types of tags in HTML. i) Empty tag The tags, which are not required to close (i.e. starting tag will be there but closing tag is not there) are called empty tag. Example: , . As is an empty tag, that’s why is not required. It is similar for also. ii) Non-empty tag The tags, which are required to close (i.e. starting tag will be there as well as closing tag will be there) are called non-empty tag. Example: . , <TITLE>.. etc. There is one special tag
, which can be said as an empty tag or non-empty tag. Sometimes it can be used with only starting tag i.e.
or sometimes it may be used with ending tag also (normally for formatting a paragraph), i.e.
…
. Basic tags TAG
DESCRIPTION
…
Indicates the beginning of HTML document Indicates the beginning of document header Indicates the beginning of document text Indicates title for the web page
… … <TITLE>…
and tags We first need to learn how to set things up properly in an HTML document (or file as it is also called). Every HTML document should first be declared that it is in fact an HTML document. When the document is completed we also need to indicate this. You do this with the tags and . Recall that HTML stands for Hyper Text Markup Language, which is the language of web page design. is the beginning tag and is the ending tag. The forward slash before the tag ( >) cancels the effect of the tag. This is true for all tags that affect text. Thus tells the browser that what follows is an HTML document and tells the browser that the HTML document is completed.
You can therefore think of the and tags as "containers", containing the entire HTML document. Therefore HTML is called a container tag. You should use the HTML element for each of your web pages. and tags Each page of your web pages should have these tags. Statements (or tags) that give information to a person visiting your website, or information such as those needed for a Search Engine are placed between the and tags. Thus the HEAD part of a document provides information about the document. You do not see this information displayed on the browser screen. It can be seen by choosing DOCUMENT SOURCE from the VIEW menu of your browser. The HEAD tag must not contain any text or normal markup tags. If it does, the browser will assume that it is in the BODY part of the document (studied below). The HEAD tag can actually be omitted, but only if you group all the tags that go in it at the top of the document. To avoid any potential problems, I would suggest that you include the HEAD tag in your own documents. <TITLE> and tags One of the statements that must included between the and tags is the TITLE of your web pages. The title in our example is " THIS IS OUR FIRST DOCUMENT". Notice that this title is placed by the browser at the very top of the screen - above the menu choices. In Netscape it reads: Netscape- [THIS IS OUR FIRST DOCUMENT] Thus Netscape has added its name to the title. The TITLE of your website or of your web page must occur between the <TITLE> and tags and you are only allowed one TITLE element per page. The information you provide in the title is also used to label the bookmark entry for your web page and is also a caption in search engine results. Therefore you should take time to make up a good descriptive title for each of your web pages. You will notice that each of our lessons has its own title that describes in general the content of the lesson. Because we do not want the title to be displayed on the browser screen, the <TITLE> and tags must be placed between the and tags. <META> tag This tag specifies information about the document to browsers, applications and search engines. With <meta> tag, we can instruct the browser to load a new document after the specified time (client-pull) or you can specify key-words for search engines to associate with your document. Attributes
• • Content Assigns values to the HTTP header fields when using REFRESH HTTP header, assign a number along with a URL to the content attribute, the browser then loads the specified URL after the specified number of seconds. • • HTTP-EQUIV This attribute indicates the HTTP header value you want to define, such as REFRESH, EXPIRES or CONTENT LANGUAGE. • • Name This attribute specifies the name of the association you are defining, such as, keywords or description. and tags After the title comes the main body of your Web page. It contains all the text and tags. It is the part that will be displayed on the browser screen. Thus the BODY element contains the actual contents of the document. Of course the tags will not be displayed on the browser screen. The tags only tell the browser how to display the information. The body of each of your Web pages should be declared with BODY tags. tells your browser that what follows is to be the body of the Web page and tells the browser that the body part of the page has ended. Thus the and tags are container tags, containing the body of your document. The BODY tag is also an optional tag. If you place all the HEAD elements first, the browser will know where the actual document body begins. The idea is good of declaring things for what they are. This way there will be no confusion for any early or ancient browser that relies on these declarations. Attributes Background =file Bgcolor=”#RRGGBB” Text =”blue” Link=”red” Vlink=”blue” Alink=”black” Topmargin=”70%” Leftmargin =”60%” Example <TITLE>THIS IS OUR FIRST DOCUMENT
FIRST HTML DOCUMENT • • Background Specifies as an image to be used to tile on the document background. Do not use with BGCOLOR. • • Bgcolor Specifies a solid color to be used for the document background. • • Text Specifies the text color. Text is black by default. • • Link Specifies the hypertext link color. The default color for the hypertext link color is light blue. • • Alink Specifies the “activated” hypertext link color. The default is red. The link changes to this color when the mouse button clicks on the link and before the mouse button is released. • • Vlink Specifies the “visited“ hypertext link color. The default is dark purple. This is the color that indicates that the link has been previously visited. • • Topmargin Specifies the top margin of the displayed area in the browser below which the text will be displayed. • • Leftmargin Specifies the left margin of the displayed area in the browser from the right of which the text will be displayed. Formatting tags FORMAT
TAGS
DESCRIPTION
Paragraph
…
...
……….
Indicates paragraph break Indicates line break Indicates preformatted text Marks up quotes that take more than a few lines Draws a horizontal line across the page Helps to make center all the elements in the document.
and attributes Use the paragraph tag to mark the beginning of a new paragraph; the ending tag,
, is optional. You could include the ALIGN attribute to specify whether the paragraph should be centered or right aligned in the page (left-aligned is the default). tag It tells the browser to wrap the text that follows onto a new line without inserting any extra space between the lines.
..
tags This tag is effective for formatting program code or similar information. Usually appears in a fixed-width font with ample space between words and lines.
..
tags The BLOCKQUOTE element marks up quotes that take more than a few lines. You use this tag when you are quoting one or more paragraphs from another source. In HTML 4.0 the
tag can take an optional CITE attribute to indicate where the quote came from. It is written like this
…
and attributes Used for drawing horizontal lines in the display page. • • Noshade –indicates solid black bar. • • Width=n (default is 100%) • • Size=n (default is 2 pixels) • • Align =left/right/center (default is center) It can be written like this.
…
tags Helps to position the text in an equal distance between the left and right edges of the document which is given within the starting
tag and ending
tag. FORMAT Character
TAGS
DESCRIPTION
…
Italicizes text
……
Underlines the text Indicates text that should appear in boldface Indicates “typewriter” font i.e. displays text in monospace format Emphasizes the text (usually italics)
… <EM>… .. <S> OR <STRIKE> … <SMALL>… <STRONG>…
Header
…
…
…
…
…
…
…
Indicates information about the author who has created the Web page in a unique font Indicates a Strikethrough text style Indicates that text display in larger font Indicates that text display in Small font Indicates strong emphasis. The browser will probably display the text in a boldface font Used to enclose program codes. First Level Heading Second Level Heading Third Level Heading Fourth Level Heading Fifth Level Heading Sixth Level Heading
and Attribute (n=1 to 6) • • ALIGN Positions the heading in the left, right or center of a document.
• • CLASS Indicates which style class applies to the element. • • ID Assigns a unique ID selector to an instance of the tag. When you then assign a style to that ID selector, it affects only that one instance of the tag.
• • STYLE Specifies style sheet commands that apply to the heading.
• • TITLE Specifies text assigned to that tag.
Example: <TITLE>DOCUMENT <STRONG>HELLO!! HEADINGS WILL BE:
THIS IS H1
THIS IS H2
THIS IS H3
THIS IS H4
THIS IS H5
THIS IS H6
THESE ARE ALL ABOUT HEADINGS
Now come to the next part of HTML <EM>DETAILS
Winserv Technology center: A.J.C Bose Road
Omit needless words
Vigorous writing is concise. A sentence should contain no unnecessary words, a paragraph should contain no unnecessary sentences, for the same reason that a drawing should have no unnecessary lines & a machine should not have any unnecessary parts.
-William Sturunk BLOCKQUOTE >
A guide to HTML
Output:
tag A tag tells the browser the correct absolute URL of the document, which might fix the relative URLs used on that page. …