My HTML
My HTML
My HTML
Page 1
Table of Content
Introduction to Web..2
Introduction to HTML.4 Body Tag.6 Title, Heading, Paragraph....7 Special Character.....8 Fonts.9 Lists10
Links in HTML..13
Images in HTML16
Tables in HTML.19
Frames in HTML23
Forms in HTML.27
Appendix.30
Page 2
Introduction to Web
What is WWW?
WWW stands for World Wide Web, and it is an advanced information retrieval system. Currently it is mostly in an experimental stage, but it is being developed rapidly. In a sense WWW competes with the Gopher information system. Notice that using WWW you can also access information in Gopher (and in FTP servers, Usenet news, etc.). WWW supports more kinds of information than Gopher, for instance pictures, graphs, colours and fonts, provided that the user's device supports them. Voice can also be delivered, if the user's device has a sound generator. WWW can also be used on a simple terminal, but then pictures are replaced by just a notation like [IMAGE]. WWW is based on hypertext, which means, among other things, that when the user is navigating on the ocean of information he can pick up an interesting word or expression within a text and request for more information about it. This does not apply to all words in a text but only to those who have been properly designated as such by the producer of the information and which are displayed on screen e.g. as underlined. In practise the use of WWW is still largely similar to the use of simpler, menu-driven information systems. In most Unix machines of the Computing Centre, WWW can be started by the command www which selects the proper mode of operation (actually, the proper program, viz. lynx or Mosaic) according to the characteristics of user's device. You will first see the HUT home page in Finnish. To access information in English, select (in the manner described below) the item HUT information in English. Alternatively, you can start WWW so that it gets you directly to the home page in English: www http://www.hut.fi/English/www.english.html This intense interest in the Web is a result of the potential it offers for communication. Using the Web, individuals or organizations can instantaneously and continuously present hypermedia--text images, movies, and sound-to a GLOBAL audience. For Web developers, this information environment demands excellent, effective content development in order to rise above the information clutter. With so much information on the Web, only that which truly meets user needs well can survive and flourish.
What is HTTP?
At first what is Protocol? Protocol means a way of communication between two or more parties. To connect two parties like client and server at first we need to establish a connection between them and after that we need to start communication in such a way so that anyone can understand each other. To establish a connection we need a special
Page 3
protocol named Transmission Control Protocol/Internet Protocol (TCP/IP). Which has become the industry-standard method of interconnecting hosts, networks, and the Internet. Now think that connection between client and server has been established. Now we need to set a way of communication like messages, so that they can understand both. This message format standard is HTTP which defines how client will send a request to the server and how the server will response. HTTP stands for "Hypertext Transfer Protocol". In case of Web Browser and Web Server, The Web Browser is HTTP Client and the Web Server is HTTP Server. More precisely the definition of HTTP protocol is a protocol designed to allow the transfer of Hypertext Markup Language (HTML) documents. An HTTP transaction is divided into four steps: 1. The browser opens a connection by using TCP/IP. 2. The browser sends a request to the server --> The request is a message and the message format follows HTTP Protocol. 3. The server sends a response to the browser --> The response also a message and the message format follows HTTP Protocol. 4. The connection is closed. So what we understand? We understand on the Internet, HTTP communication generally takes place over TCP connections. The default port is 80 but other ports can be used.. HTTP Protocol is Connection less: The protocol is called connection less because An HTTP client opens a connection and sends a request message to the HTTP server, After that the server then returns a response message containing the resource which was requested. After delivering the response, the server closes the connection unlike other protocol likes FTP, which makes HTTP Protocol is a connection less protocol. HTTP protocol is State less: When the server responded of client request, the connection between client and server is closed means forgotten. There is no "Tracking System" between client and server. The HTTP server takes every request as a new request means never maintain any connection information between transactions. But there are some ways to maintain states between client and server which i have already described in my previous article: "Passing data/parameters/values from one aspx page to another aspx page".
What is HTTPS?
HTTP is Hyper Text Transport Protocol and is transmitted over the wire via PORT 80(TCP). You normally use HTTP when you are browsing the web, its not secure, so someone can eavesdrop on the conversation between your computer and the web server. HTTPS (Hypertext Transfer Protocol over Secure Socket Layer, or HTTP over SSL) is a Web protocol developed by Netscape and built into its browser that encrypts and decrypts user page requests as well as the pages that are returned by the Web server. HTTPS is really just the use of Netscape's Secure Socket Layer (SSL) as a sublayer under its regular HTTP application layering. (HTTPS uses port 443 instead of HTTP port 80 in its interactions with the lower layer, TCP/IP.) SSL uses a 40-bit key size for the RC4 stream encryption algorithm,new-age browsers use 128-bit key size which is more secure than the former, it is considered an adequate degree of encryption for commercial exchange.HTTPS is normally used in login pages, shopping/commercial sites.
Page 4
HTML Elements
1. HTML tags are surrounded with angle brackets (< >). 2. HTML tags are not technically case sensitive, but for good practice (xHTML compliance), always use lowercase. 3. HTML tags are often in pairs with a starting tag and ending tag (<body></body>). 4. HTML tags must have a closing tag. For paired tags, this means the second tag: </p>, for others, the closing slash is in the tag itself: <br /> (xHTML compliance) 5. "Nested" HTML tags should close in the reverse order of the opening tags: <body> <strong>Curriculum Vitae</strong> </body> 6. Some tags can have properties (or "attributes") which further refine the effects of the tag: <p class="pink"> <img alt="logo">
Page 5
Attributes
Tags can also have attributes, which are extra bits of information. Attributes appear inside the opening tag and their value is always inside quotation marks. They look something like <tag attribute="value">Margarine</tag>. We will come across tags with attributes later.
Page 6
Page 7
Page Title
All HTML pages should have a page title. To add a title to your page, change your code so that it looks like this: <head> <title>Basic Web Sample</title> </head>
Headings
Headings are defined with the <h1> to <h6> tags. <h1> defines the largest heading. <h6> defines the smallest heading. <h1>This is First-Level Heading</h1> <h2>Second-Level Heading</h2> <h3>Third-Level Heading</h3> <h4>Fourth-Level Heading</h4> <h5>Fifth-Level Heading</h5> <h6>Sixth-Level Heading </h6> HTML automatically adds an extra blank line before and after a heading.
Paragraphs
Paragraphs are defined with the <p> tag. <p>This is a paragraph</p> <p>This is another paragraph</p> HTML automatically adds an extra blank line before and after a paragraph.
Preformatted Text
<pre> The ability to output preformatted text is needed in HTML because the usual behaviour is to throw unnecessary whitespace away. For example: <p> Cascading Style Sheets from World WideWeb Consortium </p> will be displayed as: Cascading Style Sheets from the World Wide Web Consortium
Page 8
This loses all the flavour of cascading that was in the original layout. Replacing p by pre as the element produces something like Cascading Style Sheets from World WideWeb Consortium
Page 9
Additional Commonly Used Character Entities Result Description Cent Pound Yen Section Copyright registered trademark Multiplication Division Entity Name ¢ £ ¥ § © ® × ÷ Entity Number ¢ £ ¥ § © ® × ÷
Fonts
Font presentation is controlled using the font tag, <font></font>.Font sizes are specified 1 through 7 with 1 as the smallest and 7 the largest. <font size="3">This text is font size 3.</font> Size 3 is the default size. That is the size that is "normal" for most browsers under most circumstances. You can experiment with the font sizes by changing the value using 1 through 7. The list below shows what these sizes look similar to what is shown below. Remember, actual font size will depend on many factors, including the size of the monitor screen.
Font size 1
Font size 2
Font size 3
Font size 4
Font size 5
Font size 6
Font size 7
It is also possible to specify font sizes relative to the settings in the browser. This is done using font size attributes that are placed with "+" or "-". An example is on the right where the size +2 is used. This means that the font should be displayed 2 sizes larger than the browser's default size. <font size="+2">This text is font size 6.</font>
Attribute color
Description Not supported in HTML5. Deprecated in HTML 4.01. Specifies the color of text
face
Not supported in HTML5. Deprecated in HTML 4.01. Specifies the font of text Not supported in HTML5. Deprecated in HTML 4.01. Specifies the size of text
size
Number
Lists
There are three types of list; unordered lists, ordered lists and definition lists. Unordered lists and ordered lists work the same way, except that the former is used for nonsequential lists with list items usually preceded by bullets and the latter is for sequential lists, which are normally represented by incremental numbers. List Tags Tag <ol> <ul> <li> <dl> <dt> <dd> Description Defines an ordered list Defines an unordered list Defines a list item Defines a definition list Defines a definition term Defines a definition description
Unordered Lists An unordered list is a list of items. The list items are marked with bullets (typically small black circles). An unordered list starts with the <ul> tag. Each list item starts with the <li> tag. <ul> <li>Bread</li> <li>Butter</li> </ul> Here is how it looks in a browser:
Page 11
Bread Butter
Inside a list item you can put paragraphs, line breaks, images, links, other lists, etc. Ordered Lists An ordered list is also a list of items. The list items are marked with numbers. An ordered list starts with the <ol> tag. Each list item starts with the <li> tag.
<ol> <li>Bread</li> <li>Butter</li> </ol> Here is how it looks in a browser: 1. Bread 2. Butter Inside a list item you can put paragraphs, line breaks, images, links, other lists, etc. Definition Lists A definition list is not a list of items. This is a list of terms and explanation of the terms. A definition list starts with the <dl> tag. Each definition-list term starts with the <dt> tag. Each definition-list definition starts with the <dd> tag. <dl> <dt>Coffee</dt> <dd>Black hot drink</dd> <dt>Milk</dt> <dd>White cold drink</dd> </dl> Here is how it looks in a browser: Coffee Black hot drink Milk White cold drink Inside a definition-list definition (the <dd> tag) you can put paragraphs, line breaks, images, links, other lists, etc.
Page 12
Exercise
1. 2. 3. 4. Create a webpage that prints your name to the screen. Create a webpage that prints the numbers 1 - 10 to the screen. Create a webpage and set its title to "This is a webpage". Create a webpage that prints the message "When was this webpage created? Check page's title for the answer." to the screen, and set the title of the page to the current date. 5. Create a webpage that prints any text of your choosing to the screen, do not include a head section in the code. 6. Print your name in green. 7. Print the numbers 1 - 10, each number being a different color. 8. Prints your name in a Tahoma font. 9. Print a paragraph with 4 - 5 sentences. Each sentence should be a different font. 10. Print a paragraph that is a description of a book, include the title of the book as well as its author. Names and titles should be underlined, adjectives should be italicized and bolded. 11. Print your name to the screen with every letter being a different heading size. 12. Print the squares of the numbers 1 - 20. Each number should be on a separate line, next to it the number 2 superscripted, an equal sign and the result. (Example: 102 = 100). 13. Prints 10 names with a line break between each name. The list should be alphabetized, and to do this place a subscripted number next to each name based on where it will go in the alphabetized list. (Example: Alan1). Print first, the unalphabetized list with a subscript number next to each name, then the alphabetized list. Both lists should have an <h1> level heading. 14. Print two paragraphs that are both indented using the command. 15. Print two lists with any information you want. One list should be an ordered list, the other list should be an unordered list. 16. Prints an h1 level heading followed by a horizontal line whose width is 100%. Below the horizontal line print a paragraph relating to the text in the heading. 17. Print some preformatted text of your choosing. (hint: use the <pre> tag). 18. Print a long quote and a short quote. Cite the author of each quote. 19. Print some deleted and inserted text of your choosing. 20. Print a definition list with 5 items. 21. Print two addresses in the same format used on the front of envelopes (senders address in top left corner, receivers address in the center). 22. Print ten acronyms and abbreviations of your choosing, each separated by two lines. Specify the data that the abbreviations and acronyms represent
Page 13
Page 14
<a href="#down">Bottom of the page</a> You should notice that a named anchor is not displayed in a special way. To link directly to the "down" section, add a # sign and the name of the anchor to the end of a URL, like this: <a href="http://www.google.com#down">Jump to down section</a> A hyperlink to the Useful Tips Section from WITHIN the file "firstpage.html" will look like this: <a name="down">Down is here</a>
Page 15
Exercise
1. Create links to five different pages on five different websites that should all open in a new window. 2. Create a page with a link at the top of it that when clicked will jump all the way to the bottom of the page. 3. Create a page with a link at the bottom of it that when clicked will jump all the way to the top of the page. 4. Create a page with a link at the top of it that when clicked will jump all the way to the bottom of the page. At the bottom of the page there should be a link to jump back to the top of the page.
Page 16
alt border
Specifies an alternate text for an image Not supported in HTML5. Deprecated in HTML 4.01. Specifies the width of the border around an image Specifies the height of an image Not supported in HTML5. Deprecated in HTML 4.01. Specifies the whitespace on left and right side of an image Specifies an image as a server-side image-map Not supported in HTML5. Specifies the URL to a document that contains a long description of an image Specifies the URL of an image
height hspace
Pixels Pixels
ismap longdesc
Ismap URL
src
URL
Page 17
usemap vspace
#mapname Pixels
Specifies an image as a client-side image-map Not supported in HTML5. Deprecated in HTML 4.01. Specifies the whitespace on top and bottom of an image Specifies the width of an image
width
Pixels
Page 18
Exercise
1. Display five different images. Skip two lines between each image. Each image should have a title. 2. Display an image that has a border of size 2, a width of 200, and a height of 200. 3. Display an image that when clicked will link to a search engine of your choice (should be opened in a new window). 4. Display an image that when clicked will link to itself and will display the image in the browser by itself.
5. NOTE: Include the alt attribute in every <img> tag in the HTML image exercises.
Page 19
Tables and the Border Attribute If you do not specify a border attribute the table will be displayed without any borders. Sometimes this can be useful, but most of the time, you want the borders to show. To display a table with borders, you will have to use the border attribute: <table border="1"> <tr> <td>Row 1, cell 1</td> <td>Row 1, cell 2</td> </tr> </table>
Headings in a Table Headings in a table are defined with the <th> tag. <table border="1"> <tr>
Page 20
<th>Heading</th> <th>Another Heading</th> </tr> <tr> <td>row 1, cell 1</td> <td>row 1, cell 2</td> </tr> <tr> <td>row 2, cell 1</td> <td>row 2, cell 2</td> </tr> </table> How it looks in a browser: Heading Another Heading
Empty Cells in a Table Table cells with no content are not displayed very well in most browsers. <table border="1"> <tr> <td>row 1, cell 1</td> <td>row 1, cell 2</td> </tr> <tr> <td>row 2, cell 1</td> <td></td> </tr> </table> How it looks in a browser: row 1, cell 1 row 1, cell 2 row 2, cell 1
Note that the borders around the empty table cell are missing (NB! Mozilla Firefox displays the border). To avoid this, add a non-breaking space ( ) to empty data cells, to make the borders visible:
Page 21
<table border="1"> <tr> <td>row 1, cell 1</td> <td>row 1, cell 2</td> </tr> <tr> <td>row 2, cell 1</td> <td> </td> </tr> </table> How it looks in a browser: row 1, cell 1 row 1, cell 2 row 2, cell 1
Table Tags Tag <table> <th> <tr> <td> <caption> <colgroup> <col> <thead> <tbody> <tfoot> Description Defines a table Defines a table header Defines a table row Defines a table cell Defines a table caption Defines groups of table columns Defines the attribute values for one or more columns in a table Defines a table head Defines a table body Defines a table footer
Page 22
Excercise
1. Create tables given in excercise Exercise 1. A B C D E F Exercise 2. A B C D E F
Exercise 5.
Exercise 6.
A B C
D E F
Page 23
<frameset rows="20%,30%,50%> <frame name="frame1" src="contents1.htm" scrolling="no"> <frame name="frame2" src="contents2.htm" scrolling="no"> <frame name="frame3" src="contents3.htm" scrolling="yes"> </frameset> The three frames appear side by side with the contents defines by the three HTML files. The third one will have scroll bars while the first two will not. Frames mainly make sense where the contents of one frame cannot update the contents of another. The obvious example is where, say, the first frame contains a list of links that define the contents of another frame. the links always remain and hitting a link updates the other frame. This is achieved by defining an attribute target which specifies the name of the frame to be updated. For example the contents of the first frame might be: <html> <title>Contents1.htm</title> <body> <a target="frame3" href="newcontents3a.htm"> Action a </a> <a target="frame3" href="newcontents3b.htm"> Action b </a> <a target="frame3" href="newcontents3c.htm"> Action c </a> <a target="frame3" href="newcontents3d.htm"> Action d </a> </body> Whichever link is hit in the first frame results in the contents of the third frame being updated. Sometimes you want to get out of the frame hierarchy. To aid this, there are some predefined values of the target attribute:
_blank The document is opened in a new window. _self The document is opened in the same frame as the link that was made. _parent The document is opened in the parent of the current frame. _top The document is opened in the complete browser window.
The need for the last of these is because framesets can be defined within framesets so that you may have to go up an unknown number of levels to break out of the current set of frames. It is difficult to define frames that are accessible. Some organisations like RNIB believe that they should never be used although W3C is not quite so dogmatic. If you can avoid using them do so. The least that should be done is to include a version of the document as a noframes element which could be used by Braille, line mode or spoken browsers. UK Government web sites have the following structure: <html> <head> <title>XXX Department</title> </head> <frameset rows="40,*"> <frame name="ukonline_toolbar" title="Latest news" src="http://www.toolbar.e-envoy.gov.uk/standard-toolbar.htm" /> <frame name="ukonline_content" title="home page of XXX"
Page 25
src="XXXHome.htm" /> <noframes> <body> <p>Welcome to the XXX web site <a href="XXXHome.htm">Enter the site</a> or go to the <a href="http://www.ukonline.gov.uk">UK online Citizen Portal</a>. </p> </body> </noframes> </frameset> </html> This adds a UK Government Logo and ticker tape news feed to all Government web sites in the top 40 pixels leaving the remainder for the Department's own content. The noframes version allows you to enter the site directly ignoring the ticker tape feed if you do not require it. If you do not need the whole frame mechanism and just want to insert a single frame in an existing page, this can be achieved using the iframe element. For example: <iframe name="inframe" width="240" height="250" scrolling="no" src="page.htm" > Links can be targetted at an iframe in the same way as a normal frame. It does reduce the frame overhead for simple usage.
Page 26
Exercise
Create Frames as given below: 1.
2.
3.
4.
5.
Page 27
The input tag is the daddy of the form world. It can take ten forms, outlined below: _ <input type="text"/> is a standard textbox. This can also have a value attribute, which sets the text in the textbox. _ <input type="password" /> is the same as the textbox, but will display asterisks instead of the actual characters that the user types. _ <input type="checkbox" /> is a checkbox, which can be toggled on and off by the user. This can also have a checked attribute, which would be used in the format <input type="checkbox" checked="checked" />. _ <input type="radio" /> is similar to a checkbox, but the user can only select one radio button in a group. This can also have a checked attribute, used in the same way as the checkbox. _ <input type="file" /> is an area that shows the files on your computer, like you see when you open or save a document in most programs. _ <input type="submit" /> is a button that when selected will submit the form. You can control the text that appears on the submit button (as you can with button and reset types - see below) with the value attribute, for example <input type="submit" value="Ooo. Look. Text on a button. Wow" />. _ <input type="image" /> is an image that when selected will submit the form. This also
Page 28
requires a src attribute, like the img tag. _ <input type="button" /> is a button that will not do anything without extra code added. _ <input type="reset" /> is a button that when selected will reset the form fields. _<input type="date" />is a field which shows calendar control to select particular date. _ <input type="hidden" /> is a field that will not be displayed and is used to pass information such as the page name that the user is on or the email address that the form should be posted to. Note that the input tag closes itself with a '/>' at the end. A textarea is, basically, a large textbox. It requires a rows and cols attribute and is used like this: <textarea rows="5" cols="20">A big load of text here</textarea> The select tag works with the option tag to make drop-down select boxes. They work like this: <select> <option value="first option">Option 1</option> <option value="second option">Option 2</option> <option value="third option">Option 3</option> </select> When the form is submitted, the value of the selected option will be sent. Similar to the checked attribute of checkboxes and radio buttons, an option tag can also have a selected attribute, which would be used in the format <option value="mouse" selected="selected">Rodent</option>. All of the tags mentioned above will look very nice presented on the page, but if you hook up your form to a form-handling program, they will all be ignored. This is because the form fields need names. So to all of the fields, the attribute name needs to be added, for example <input type="text" name="talkingsponge" />
Page 29
Exercise
Create a form as given below:
Minor Project
Create a website by using all the concepts of HTML studied till now.
Page 30
Code Example <!--This can be viewed in the HTML part of a comment document-->
Name anchor bold big (text) body of document line break center
<A HREF="http://www.yourdomain.com/">Visit Our Visit Our Site Site</A> <B>Example</B> <BIG>Example</BIG> <BODY>The content of your page</BODY> Example Example Contents of your webpage
The contents of your page<BR>The contents of your The contents of your page page The contents of your page <CENTER>This will center your contents</CENTER> This will center your contents Definition Term Definition of the term Definition Term Definition of the term Definition Term Definition of the term Definition Term Definition of the term
<DD>
<DL> <DT>Definition Term definition <DD>Definition of the term description <DT>Definition Term <DD>Definition of the term </DL> <DL> <DT>Definition Term <DD>Definition of the term <DT>Definition Term <DD>Definition of the term </DL> <DL> <DT>Definition Term <DD>Definition of the term <DT>Definition Term <DD>Definition of the term </DL> This is an <EM>Example</EM> of using the emphasis tag <EMBED src="yourfile.mid" width="100%" height="60" align="center">
<DL>
definition list
<DT>
definition term
Definition Term Definition of the term Definition Term Definition of the term This is an Example of using the emphasis tag
<EM> <EMBED>
<EMBED>
embed object
Music will begin playing when your page is loaded and will only play one time. A control panel will be displayed to enable your visitors to stop the music. Example (Tip) Example (Tip)
<FONT> <FONT>
font font
<FONT>
font
<FORM>
<FORM action="mailto:[email protected]"> Name: <INPUT name="Name" value="" size="10"><BR> form Email: <INPUT name="Email" value="" size="10"><BR> <CENTER><INPUT type="submit"></CENTER> </FORM> heading 1 <H1>Heading 1 Example</H1>
heading 2 heading 3 heading 4 heading 5 heading 6 heading of document
Heading 1 Example Heading 2 Example Heading 3 Example Heading 4 Example Heading 5 Example Heading 6 Example Nothing will show Contents of your webpage (Tip) Contents of your webpage
<H2>Heading 2 Example</H2> <H3>Heading 3 Example</H3> <H4>Heading 4 Example</H4> <H5>Heading 5 Example</H5> <H6>Heading 6 Example</H6> <HEAD>Contains elements describing the document</HEAD>
<HR>
horizontal rule
<HR>
<HR>
horizontal rule
Contents of your webpage <HR WIDTH="50%" SIZE="3"> Contents of your webpage Contents of your webpage <HR WIDTH="50%" SIZE="3" NOSHADE> Contents of your webpage <HR WIDTH="75%" COLOR="#FF0000" SIZE="4"> <HR WIDTH="25%" COLOR="#6699FF" SIZE="6"> <HTML><HEAD><META><TITLE>Title of your webpage</TITLE></HEAD><BODY>Webpage contents</BODY></HTML> <I>Example</I> <IMG SRC="Earth.gif" WIDTH="41" HEIGHT="41" BORDER="0" ALT="a sentence about your site"> Example 1: Example 1: (Tip) Contents of your webpage Contents of your webpage Contents of your webpage Contents of your webpage Contents of your webpage Example
<HR>
horizontal rule
horizontal rule
<INPUT>
<FORM METHOD=post ACTION="/cgiinput field bin/example.cgi"> <INPUT type="text" size="10" maxlength="30"> <INPUT type="Submit" VALUE="Submit"> </FORM>
input field
Submit
<INPUT> (Internet
Example 2:
Page 32
Example 2: (Tip)
Explorer)
<FORM METHOD=post ACTION="/cgibin/example.cgi"> <INPUT type="text" STYLE="color: #FFFFFF; fontfamily: Verdana; font-weight: bold; font-size: 12px; background-color: #72A4D2;" size="10" maxlength="30"> <INPUT type="Submit" VALUE="Submit"> </FORM> Example 4:
Submit
Example 4: (Tip) <FORM METHOD=post ACTION="/cgibin/example.cgi"> Enter Your Comments:<BR> input field <TEXTAREA wrap="virtual" name="Comments" rows=3 cols=20 MAXLENGTH=100></TEXTAREA><BR> <INPUT type="Submit" VALUE="Submit"> <INPUT type="Reset" VALUE="Clear"> </FORM> Example 5: <FORM METHOD=post ACTION="/cgibin/example.cgi"> <CENTER> Select an option: <SELECT> <OPTION >option 1 input field <OPTION SELECTED>option 2 <OPTION>option 3 <OPTION>option 4 <OPTION>option 5 <OPTION>option 6 </SELECT><BR> <INPUT type="Submit" VALUE="Submit"></CENTER> </FORM> Example 6: Example 6: (Tip) <FORM METHOD=post ACTION="/cgibin/example.cgi"> Select an option:<BR> <INPUT type="radio" name="option"> Option 1 <INPUT type="radio" name="option" CHECKED> Option 2 <INPUT type="radio" name="option"> Option 3 input field <BR> <BR> Select an option:<BR> <INPUT type="checkbox" name="selection"> Selection 1 <INPUT type="checkbox" name="selection" CHECKED> Selection 2 <INPUT type="checkbox" name="selection"> Selection 3 <INPUT type="Submit" VALUE="Submit">
Page 33
<INPUT>
Submit
Clear
<INPUT>
Submit
Select an option: Option 1 Option 2 Option 3 Select an option: Selection 1 Selection 2 Selection 3
Submit
<INPUT>
</FORM> Example 1: Example 1: (Tip) <MENU> <LI type="disc">List item 1 <LI type="circle">List item 2 <LI type="square">List item 3 </MENU>
<LI> list item o
Example 2: <OL type="i"> <LI>List item 1 <LI>List item 2 <LI>List item 3 <LI>List item 4 </OL>
Example 2: i. ii. iii. iv. List item 1 List item 2 List item 3 List item 4
<LINK>
link
Visit our <A Visit our site HREF="http://www.yourdomain.com/">site</A> <MARQUEE bgcolor="#CCCCCC" loop="-1" scrollamount="2" width="100%">Example Marquee</MARQUEE> <MENU> <LI type="disc">List item 1 <LI type="circle">List item 2 <LI type="square">List item 3 </MENU> <META name="Description" content="Description of your site"> <META name="keywords" content="keywords describing your site">
o
<MENU>
menu
<META>
meta
<META HTTP-EQUIV="Refresh" Nothing will show CONTENT="4;URL=http://www.yourdomain.com/"> <META http-equiv="Pragma" content="no-cache"> <META name="rating" content="General"> <META name="ROBOTS" content="ALL"> <META NAME="ROBOTS" content="NOINDEX,FOLLOW"> Example 1: <OL> <LI>List item 1 <LI>List item 2 <LI>List item 3 <LI>List item 4 </OL> Example 2: <OL type="a"> <LI>List item 1 <LI>List item 2
Page 34
Nothing will show (Tip) Nothing will show (Tip) Nothing will show (Tip) Nothing will show (Tip) Example 1: 1. 2. 3. 4. List item 1 List item 2 List item 3 List item 4
<OL>
ordered list
<LI>List item 3 <LI>List item 4 </OL> <FORM METHOD=post ACTION="/cgibin/example.cgi"> <CENTER> Select an option: <SELECT> <OPTION>option 1 <OPTION SELECTED>option 2 <OPTION>option 3 <OPTION>option 4 <OPTION>option 5 <OPTION>option 6 </SELECT><BR> </CENTER> </FORM>
<OPTION>
listbox option
This is an example displaying the use of the paragraph This is an example displaying tag. <P> This will create a line break and a space the use of the paragraph tag. between lines. Attributes: Example 1:<BR> <BR> <P align="left"> This is an example<BR> displaying the use<BR> of the paragraph tag.<BR> <BR> paragraph Example 2:<BR> <BR> <P align="right"> This is an example<BR> displaying the use<BR> of the paragraph tag.<BR> <BR> Example 3:<BR> <BR> <P align="center"> This is an example<BR> displaying the use<BR> of the paragraph tag.
small (text) strong emphasis
This will create a line break and a space between lines. Attributes: Example 1: This is an example displaying the use of the paragraph tag. Example 2: This is an example displaying the use of the paragraph tag. Example 3: This is an example displaying the use of the paragraph tag. Example Example Example 1: Column 1 Column 2
<P>
<SMALL> <STRONG>
<SMALL>Example</SMALL> <STRONG>Example</STRONG> Example 1: <TABLE BORDER="4" CELLPADDING="2" CELLSPACING="2" WIDTH="100%"> <TR> <TD>Column 1</TD> <TD>Column 2</TD> </TR>
Page 35
<TABLE>
Table
Example 2:
Column 1
Column 2
Example 3: <TABLE BORDER="2" BORDERCOLOR="#336699" CELLPADDING="2" CELLSPACING="2" WIDTH="100%"> Column 1 <TR> Row 2 <TD>Column 1</TD> <TD>Column 2</TD> </TR> </TABLE> Example 3: <TABLE CELLPADDING="2" CELLSPACING="2" WIDTH="100%"> <TR> <TD BGCOLOR="#CCCCCC">Column 1</TD> <TD BGCOLOR="#CCCCCC">Column 2</TD> </TR> <TR> <TD>Row 2</TD> <TD>Row 2</TD> </TR> </TABLE> <TABLE BORDER="2" CELLPADDING="2" CELLSPACING="2" WIDTH="100%"> <TR> table data <TD>Column 1</TD> <TD>Column 2</TD> </TR> </TABLE> <DIV align="center"><TABLE> <TR> <TH>Column 1</TH> <TH>Column 2</TH> <TH>Column 3</TH> </TR> <TR> <TD>Row 2</TD> <TD>Row 2</TD> <TD>Row 2</TD> </TR> <TR> <TD>Row 3</TD> <TD>Row 3</TD> <TD>Row 3</TD> </TR> <TR> <TD>Row 4</TD> <TD>Row 4</TD> <TD>Row 4</TD> </TR> </TABLE>
Page 36
Column 2 Row 2
<TD>
Column 1
Column 2
<TH>
table header
</DIV>
<TITLE> document title
<TITLE>Title of your webpage</TITLE> <TABLE BORDER="2" CELLPADDING="2" CELLSPACING="2" WIDTH="100%"> <TR> <TD>Column 1</TD> <TD>Column 2</TD> </TR> </TABLE> <TT>Example</TT> <U>Example</U>
<TR>
table row
Column 1
Column 2
<TT> <U>
teletype underline
<UL>
Example 1:<BR> <BR> <UL> <LI>List item 1 <LI>List item 2 </UL> <BR> unordered Example 2:<BR> list <UL type="disc"> <LI>List item 1 <LI>List item 2 <UL type="circle"> <LI>List item 3 <LI>List item 4 </UL> </UL>
Example 2:
Page 37
HTML 5
HTML 5 the fifth revision of the HTML standard. Its core aims have been to improve the language with support for the latest multimedia while keeping it easily readable by humans and consistently understood by computers and devices (web browsers, parsers, etc.).Basically HTML5 has its many new syntactical features, which include the <video>, <audio>, and <canvas> elements, as well as the integration of SVG content. Due to these new elements, it will be very easy to integrate multimedia and graphical content to web without using flash and third party plugins. There are also another new elements like <section>, <article>, <header> and <nav> which enrich the semantic value of the document. Other major advantages of HTML5 are described below.
HTML5 Features
1. Mutuality: Due to usability purpose the web sites made by developers are highly interactive nowadays and for this developers need to include fluid animations, stream video, play music and Social Network sites like Facebook and Twitter into the websites. Till now they have only the option to integrate it with the help of Flash or Silverlight, Flex or javascript like tools. But these consume so much time to develop and even the complexity of web application also increased. But now with the help of HTML5 it is possible to embed video and audio, high quality drawings, charts and animation and many other rich content without using any plugins and third party programmas as the functionality is built into the browser.
2. Cleaner markup / Improved Code HTML 5 will enable web designers to use cleaner, neater code, we can remove most div tags and replace them with semantic HTML 5 elements.
3. Improved Semantics Now it is easy to see which parts of the page are headers, nav, footers, aside, etc as the tags are specific for these all and most importantly know what their meaning and purpose is in whole the format. By using HTML5 elements we can increase the semantic value of the web page as the codes are very standardized.
4. Elegant forms HTML5 enables designer to use more fancier forms. Even it makes form validation native to HTML, User interface enhancements and reduced need for JavaScript (only needed in browsers that dont support form types). There will be different type of text inputs, search and different fields for different purpose.
5. Consistency As websites adopt the new HTML5 elements we will see more greater consistency in terms of the HTML used to code a web page on one site compared to another. This will make it more easier for designers and developers to immediately understand how a web page is structured.
Page 38
6. Improved Accessibility Different technologies can elaborate on the features with the help of HTML5, as they can Immediately make more detailed understanding of the structure of a page by take a look at HTML5 elements it has.
7. Fulfill the need of Web application Many new features and standards have emerged as part of HTML 5. Once you detect the available features in todays browsers, you can take advantage of those features in your application. Main focus of HTML5 is to make easier application with easy front-ends, drag and drop tools, discussion boards, wikis and other useful elements.
8. Offline Application cache All browsers have some kind of caching m After a sometime, you open up your laptop and click the Back button in the browser hoping to see the previous page that was opened. However, as you are not connected to the internet and the browser didnt cache the page properly, you are unable to view that page. You then click the Forward button thinking that at least that page will load, but it doesnt. You need to reconnect to the internet to be able to view the pages. HTML 5, thankfully, provides a smarter solution. While building the site, the developer can specify the files that the browser should cache. So, even if you refresh the page when you are offline, the page will still load correctly. This sort of caching has several advantages like offline browsing, files load much faster and reduced load on server
9. Client-side database While cookies have been used to track unique user data for years, they have serious disadvantages. The largest flaw is that all of your cookie data is added to every HTTP request header. This can end up having a measurable impact on response time. So a best practice is to reduce cookie size. With HTML5 we can do better by using sessionStorage and localStorage(two different storage in HTML5) in place of cookies. It is not a permanent database, but enables you to store structured data, temporarily.
10. Geolocation support With help of Geolocation any one can find out where you are in the world and sharing that information with people. There is different ways to figure out where you are your IP address, your wireless network connection, which cell tower your phone is talking to, or dedicated GPS hardware that calculates latitude and longitude from information sent by satellites in the sky. But The new HTML5 geolocation APIs make location, whether generated via GPS or other methods, directly available to any HTML5-compatible browser-based application.
The <canvas> element for 2D drawing The <video> and <audio> elements for media playback Support for local storage New content-specific elements, like <article>, <footer>, <header>, <nav>, <section> New form controls, like calendar, date, time, email, url, search
Page 39
HTML <Canvas> The HTML5 <canvas> tag is used to draw graphics, on the fly, via scripting (usually JavaScript). However, the <canvas> element has no drawing abilities of its own (it is only a container for graphics) - you must use a script to actually draw the graphics. The getContext() method returns an object that provides methods and properties for drawing on the canvas. This reference will cover the properties and methods of the getContext("2d") object, which can be used to draw text, lines, boxes, circles, and more - on the canvas. Attributes Property fillStyle strokeStyle shadowColor shadowBlur shadowOffsetX shadowOffsetY Description Sets or returns the color, gradient, or pattern used to fill the drawing Sets or returns the color, gradient, or pattern used for strokes Sets or returns the color to use for shadows Sets or returns the blur level for shadows Sets or returns the horizontal distance of the shadow from the shape Sets or returns the vertical distance of the shadow from the shape
HTML <Audio> and <Vedio> HTML5 introduces built-in media support via the <audio> and <video> elements, offering the ability to easily embed media into HTML documents. Attributes
Description Returns an AudioTrackList object representing available audio tracks Sets or returns if the audio/video should start playing as soon as it is loaded Returns a TimeRanges object representing the buffered parts of the audio/video
buffered
Page 40
controller
Returns the MediaController object representing the current media controller of the audio/video Sets or returns if the audio/video should display controls (like play/pause etc.) Sets or returns the CORS settings of the audio/video Returns the URL of the current audio/video Sets or returns the current playback position in the audio/video (in seconds) Sets or returns if the audio/video is muted by default Sets or returns the default speed of the audio/video playback Returns the length of the current audio/video (in seconds) Returns if the playback of the audio/video has ended or not Returns a MediaError object representing the error state of the audio/video Sets or returns if the audio/video should start over again when finished Sets or returns a the group the audio/video belongs to (used to link multiple audio/video elements) Sets or returns if the audio/video is muted or not Returns the current network state of the audio/video Sets or returns if the audio/video is paused or not Sets or returns the speed of the audio/video playback Returns a TimeRanges object representing the played parts of the audio/video Sets or returns if the audio/video should be loaded when the page loads Returns the current ready state of the audio/video
controls
loop mediaGroup
preload readyState
Page 41
seekable
Returns a TimeRanges object representing the seekable parts of the audio/video Returns if the user is currently seeking in the audio/video Sets or returns the current source of the audio/video element Returns a Date object representing the current time offset Returns a TextTrackList object representing the available text tracks Returns a VideoTrackList object representing the available video tracks Sets or returns the volume of the audio/video
Example Embedding media in your HTML document is trivial: <video src="http://v2v.cc/~j/theora_testsuite/320x240.ogg" controls> Your browser does not support the <code>video</code> element. </video> This example plays a sample video, with playback controls, from the Theora web site. Here is an example for embedding audio into your HTML document <audio src="/test/audio.ogg"> <p>Your browser does not support the audio element.</p> </audio> The src attribute can be a URL of the audio file or the path to the file on the local system. <audio src="audio.ogg" controls autoplay loop> <p>Your browser does not support the audio element </p> </audio> This code example uses attributes of the <audio> element:
controls : Displays the standard HTML5 controls for the audio on the web page. autoplay : Makes the audio play automatically. loop : Make the audio repeat (loop) automatically.
Page 42
<audio src="audio.mp3" preload="auto" controls></audio> The preload attribute is used in the audio element for buffering large files. It can take one of 3 values:
"none" does not buffer the file "auto" buffers the media file "metadata" buffers only the metadata for the file Multiple source files can be specified using the <source> element in order to provide video or audio encoded in different formats for different browsers. For instance: <video controls> <source src="foo.ogg" type="video/ogg"> <source src="foo.mp4" type="video/mp4"> Your browser does not support the <code>video</code> element. </video> HTML <Article> The HTML <article> tag is used to represent an article. More specifically, the content within the <article> tag is independent from the other content on the site (even though it could be related). By "independent" I mean that its contents could stand alone, for example in syndication. Examples of article content could include a forum post, a newspaper article, a blog entry, or a user-submitted comment. The <article> tag was introduced in HTML 5. The <article> tag is supported in Internet Explorer 9+, Firefox, Opera, Chrome, and Safari. Example: <article> <h1>Internet Explorer 9</h1> <p>Windows Internet Explorer 9 (abbreviated as IE9) was released to the public on March 14, 2011 at 21:00 PDT.....</p> </article> HTML <Header> Purpose of the header element is to hold any of the h1 to h6 elements, a hggroup element, a table of content, a search form or associated logos. This element adds a semantic value to your HTML5 page. In general it may be said as a container element which may contain an introductory or a navigational content. header element has nothing to do with head element. And, it does not introduce any new section, but it is the head of a section.
Page 43
Example <header> <h1>Internet Explorer 9</h1> <p><time pubdate datetime="2011-03-15"></time></p> </header> HTML <Footer> The <footer> tag defines a footer for a document or section. A <footer> element should contain information about its containing element. A footer typically contains the author of the document, copyright information, links to terms of use, contact information, etc. Example <footer> <p>Posted by: Hege Refsnes</p> <p><time pubdate datetime="2012-03-01"></time></p> </footer> HTML <nav> The <nav> tag defines a section of navigation links. Not all links of a document must be in a <nav> element. The <nav> element is intended only for major block of navigation links. Example <nav> <a href="/html/">HTML</a> | <a href="/css/">CSS</a> | <a href="/js/">JavaScript</a> | <a href="/jquery/">jQuery</a> </nav> HTML <section> The <section> tag defines sections in a document. Such as chapters, headers, footers, or any other sections of the document. Attributes Attribute accesskey class Description Specifies a shortcut key to activate/focus an element Specifies one or more classnames for an element (refers to a class in a style sheet)
Page 44
contenteditable contextmenu
Specifies whether the content of an element is editable or not Specifies a context menu for an element. The context menu appears when a user right-clicks on the element Specifies the text direction for the content in an element Specifies whether an element is draggable or not Specifies whether the dragged data is copied, moved, or linked, when dropped Specifies that an element is not yet, or is no longer, relevant Specifies a unique id for an element Specifies the language of the element's content Specifies whether the element is to have its spelling and grammar checked or not Specifies an inline CSS style for an element Specifies the tabbing order of an element Specifies extra information about an element Specifies whether an element's value are to be translated when the page is localized, or not.
Example <section> <h1>WWF</h1> <p>The World Wide Fund for Nature (WWF) is....</p> </section> HTML <>
Page 45