Unit-2 Dynamic HTML
Unit-2 Dynamic HTML
Unit-2
Dynamic HTML
DHTML stands for Dynamic HTML. It is NOT a language or a web standard. DHTML is the art of combining HTML, JavaScript, DOM, and CSS. According to the World Wide Web Consortium (W3C): "Dynamic HTML is a term used by some vendors to describe the combination of HTML, style sheets and scripts that allows documents to be animated."
DHTML Technologies
Below is a listing of DHTML technologies: HTML 4.0 The HTML 4.0 standard has rich support for dynamic content like: HTML supports JavaScript HTML supports the Document Object Model (DOM) HTML supports HTML Events HTML supports Cascading Style Sheets (CSS) DHTML is about using these features to create dynamic and interactive web pages. JavaScript JavaScript is the scripting standard for HTML. DHTML is about using JavaScript to control, access and manipulate HTML elements. HTML DOM The HTML DOM is the W3C standard Document Object Model for HTML. It defines a standard set of objects for HTML, and a standard way to access and manipulate them. DHTML is about using the DOM to access and manipulate HTML elements. CSS CSS is the W3C standard style and layout model for HTML. It allows web developers to control the style and layout of web pages. HTML 4 allows dynamic changes to CSS. DHTML is about using JavaScript and DOM to change the style and positioning of HTML elements.
Web Designing
Web pages and Web sites can be static pages, or can be programmed to be dynamic pages that automatically adapt content or visual appearance depending on a variety of factors, such as input from the end-user, input from the Webmaster or changes in the computing environment (such as the site's associated database having been modified).
The software may be a professional web design program like Dreamweaver or a simple webbased interface like WordPress. The Internet connection serves as the medium for uploading the content to the web server. Large sites may use a dedicated web host, but many smaller sites often reside on shared servers, which host multiple websites. Most blogs are published on public web servers through a free service like Blogger. Since web publishing doesn't require physical materials such as paper and ink, it costs almost nothing to publish content on the web. Therefore, anyone with the three requirements above can be a web publisher. Additionally, the audience is limitless since content posted on the web can be viewed by anyone in the world with an Internet connection. These advantages of web publishing have led to a new era of personal publishing that was not possible before. Publishing Process The three essential steps to publish your website onto the web are: 1. Creating your website: First you have to create a website. Depending on your level on knowledge in web development you have the following options. Either you can create the site yourself through manual programming in an editor program like DreamWeaver, EditPlus or Notepad. Otherwise there are a number of open source alternatives available without any requirement of prior programming knowledge. 2. Get a hosting plan: Next step is to find somewhere online to put your website files and assign an address to that somewhere. Any given hosting plan include storage space on a web server and a domain name registration. Depending on what size your website has and potential traffic volume it's going to generate, you get a hosting plan based on three factors - storage space, bandwidth and CPU.
Information Gathering
The first step in designing a successful web site is to gather information. Many things need to be taken into consideration when the look and feel of your site is created. This first step is actually the most important one, as it involves a solid understanding of the company it is created for. It involves a good understanding of you - what your business goals and dreams are, and how the web can be utilized to help you achieve those goals. Certain things to consider are: Purpose: What is the purpose of the site? Do you want to provide information, promote a service, sell a product ? Goals: What do you hope to accomplish by building this web site? Two of the more common goals are either to make money or share information. Target Audience: Is there a specific group of people that will help you reach your goals? It is helpful to picture the ideal person you want to visit your web site. Consider their age, sex or interests - this will later help determine the best design style for your site. Content: What kind of information will the target audience be looking for on your site? Are they looking for specific information, a particular product or service, online ordering?
Planning
Using the information gathered from phase one, it is time to put together a plan for your web site. This is the point where a site map is developed. The site map is a list of all main topic areas of the site, as well as sub-topics, if applicable. This serves as a guide as to what content will be on the site, and is essential to developing a consistent, easy to understand navigational system. A good user interface creates an easy to navigate web site, and is the basis for this.
Development
The developmental stage is the point where the web site itself is created. At this time, your web designer will take all of the individual graphic elements from the prototype and use them to create the actual, functional site. This is typically done by first developing the home page, followed by a shell for the interior pages. The shell serves as a template for the content pages of your site, as it contains the main navigational structure for the web site. Once the shell has been created, your designer will take your content and distribute it throughout the site, in the appropriate areas. Elements such as interactive contact forms, flash animations or ecommerce shopping carts are implemented and made functional during this phase, as well. This involves writing valid XHTML / CSS code that complies to current web standards, maximizing functionality, as well as accessibility for as large an audience as possible.
Testing
At this point, your web designer will attend to the final details and test your web site. They will test things such as the complete functionality of forms or other scripts, as well last testing for last minute compatibility issues (viewing differences between different web browsers), ensuring that your web site is optimized to be viewed properly in the most recent browser versions. A good web designer is one who is well versed in current standards for web site design and development. The basic technologies currently used are XHTML and CSS (Cascading Style Sheets). As part of testing, your designer should check to be sure that all of the code written for your web site validates. Valid code means that your site meets the current web development standards - this is helpful when checking for issues such as cross-browser compatibility as mentioned above. Once you give your web designer final approval, it is time to deliver the site. An FTP (File Transfer Protocol) program is used to upload the web site files to your server. Most web designers offer domain name registration and web hosting services as well. Once these accounts have been setup, and your web site uploaded to the server, the site should be put through one last run-through. This is just precautionary, to confirm that all files have been uploaded correctly, and that the site continues to be fully functional. This marks the official launch of your site, as it is now viewable to the public.
Maintenance
The development of your web site is not necessarily over, though. One way to bring repeat visitors to your site is to offer new content or products on a regular basis. Most web designers will be more than happy to continue working together with you, to update the information on
History of HTML A markup language combines text as well as coded instructions on how to format that text and the term "markup" originates from the traditional practice of 'marking up' the margins of a paper manuscript with printer's instructions. Nowadays, however, if you mention the term 'markup' to any knowledgeable web author, the first thing they are likely to think of is 'HTML'. In the Beginning HTML which is short for HyperText Markup Language is the official language of the World Wide Web and was first conceived in 1990. HTML is a product of SGML (Standard Generalized Markup Language) which is a complex, technical specification describing markup languages, especially those used in electronic document exchange, document management, and document publishing. HTML was originally created to allow those who were not specialized in SGML to publish and exchange scientific and other technical documents. HTML especially facilitated this exchange by
HTML Rules
An HTML document is built upon ASCII text that has been marked up with tags looking like: <TAGNAME> and </TAGNAME> The purpose of these tags is to specify an device-free . For example, first level headers would be marked as: <H1>This is a First Level Header</H1>
Note: Element names are and <STRONG> are all the same.
always
case-insensitive,
so <strong>, <sTRONG>,
An element's attributes define various properties for the element. For example, the element takes a face attribute to provide the different font style:
font
An attribute is included in the start tag only--never the end tag--and takes the form Attribute-name="Attribute-value". The attribute value is delimited by single or double quotes. The quotes are optional if the attribute value consists solely of letters in the range A-Z and a-z, digits (0-9), hyphens ("-"), periods ("."), underscores ("_"), and colons (":").
Note: Attribute names are case-insensitive, but attribute values may be case-sensitive.
<head>
The head
meta tags
</head> <body>
header <h1>Level 1 heading</h1>
The body
break <br>This is a new line link <a href="robot.html">This is a link</a> image <img src="robot.gif"> list <ul>
<li>first item</li> <li>second item</li> <li>...</li> </ul> comment <!--This is a comment tag-it is invisible-->
</body> </html>
DOCTYPE Declaration
The DOCTYPE declaration is the first part of coding that you should enter in your HTML document. This is required if you wish to validate your document with the W3C's validation service. Web browsers need to know what version of HTML/XHTML your page is written in to process the code correctly. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> The HTML Tags All HTML documents contain a <html> and </html> pair of tags. These tags identify the document's contents as HTML to the browser. The <html> tag goes in the line right under your DOCTYPE declaration. </html> is the last line of coding in your document. Opening html tag: <html> The Head Tags-Opening Tag The <head> and </head> tags identify the document's head area. The information between these two tags is not visible on your page. Opening head tag: <Head>
10
The Title Tags The title tag creates the page title that is seen in the title bar of the web page. <Title>My Web Page</Title> Meta Tag The meta tags provide information about your web page. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> In addition to the title element, the head may also contain: base: defines base URLs for links or resources on the page, and target windows in which to open linked content link: refers to a resource of some kind, most often to a style sheet that provides instructions about how to style the various elements on the web page meta: provides additional information about the page; for example, which character encoding the page uses, a summary of the pages content, instructions to search engines about whether or not to index content, and so on object: represents a generic, multipurpose container for a media object script: used either to embed or refer to an external script style: provides an area for defining embedded (page-specific) CSS styles All of these elements are optional and can appear in any order within the head. Note that none of the elements listed here actually appear on the rendered page, but they are used to affect the content on the page, all of which is defined inside the body element. Closing Head Tag The closing head tag defines the end of the document's head section. </Head> The Body The body tags surround the body (contents) of your web page. <Body> The Body of the HTML Document </Body>
11
Closing HTML Tag The closing HTML tag is the last line in your HTML document. Don't put anything after this tag! Your page will not validate if you do. </Html>
Core Attributes
HTML 4.0 has a set of four core attributes: ID, CLASS, STYLE and TITLE attribute. 1. ID Attribute: The ID attribute uniquely identifies an element within a document. No two elements can have the same ID value in a single document. The attribute's value must begin with a letter in the range A-Z or a-z, digits (0-9), hyphens ("-"), underscores ("_"), colons (":"), and periods ("."). The value is case-sensitive. The following example uses the ID attribute to identify each of the first two paragraphs of a document: <P ID=firstparagraph>This is my first paragraph.</P> <P ID=secondparagraph>This is my second paragaph.</P> In the example, both paragraphs could have style rules associated with them through their ID attributes. The following Cascading Style Sheet defines unique colors for the two paragraphs: <style type="text/css"> #firstparagraph { font-weight:bold; } #secondparagraph { font-style:italic; } </style> Output: This is my first paragraph. This is my second paragraph. Note: A style sheet rule could be put <head>..<style>...</style>...</head>) of a document. in the head i.e.(
2. Class Attribute: The class attribute is used to indicate the class or classes that a tag might belong to. Like id, class is used to associate a tag with a name, so
12
Tooltips set with title values are often found on links, form fields, images, and anywhere where an extra bit of information is required. The core attributes might not make a great deal of sense at this time because generally they are most useful with scripting and style sheets, but keep in mind that these four attributes are assumed with every tag that is introduced for the rest of this chapter.
Language Attributes
One major goal of HTML 4 was to provide better support for languages other than English. The use of other languages might require that text direction be changed from left to right across the screen to right to left. Nearly all HTML elements now support the dir attribute, which can be used to indicate text direction as either ltr (left to right) or rtl (right to left). For example:
13
Core Events
The last major aspect of modern markup initially introduced by HTML 4 was the increased possibility of adding scripting to HTML documents. In preparation for a more dynamic Web, a set of core events has been associated with nearly every HTML element. Most of these events are associated with a user doing something. For example, the user clicking an object is associated with an onclick event attribute. So, <p onclick="alert('Ouch!');"> Press this paragraph </p> would associate a small bit of scripting code with the paragraph event, which would be triggered when the user clicks the paragraph. In reality, the event model is not fully supported by all browsers for all tags, so the previous example might not do much of anything.
14
Linking Basis
The acronym HTML stands for hypertext, or text that is linked to other information. HTML enables us to link to other Web pages, as well as graphics, multimedia, e-mail addresses, newsgroups, and downloadable files. Anything you can access through your browser can be linked to from within an HTML document. Web pages can contain links that take you directly to other pages and even specific parts of a given page. These links are known as hyperlinks. A hyperlink is text, an image, or any other object in an HTML document that can be clicked in order to gain access to another web document. Normally, links are distinguished as being external or internal to the current page. External web site link provides access to another web site that is not part of the current web site, such as going to www.yahoo.com from our current website mypage.html. An internal web site link provides access to another web page which is apart of the original web site, such as going to the next article in this guide from this web page. Finally, an internal document section link points to a region within a web page document.
External Linking
The <a> tag itself doesnt serve much purpose without its attributes. The most common attribute is href, which is short for hypertext reference: it tells the browser where to find the information to which you are linking. The text included in between the opening and closing a tag is what the person viewing your Web page can click. In most cases, this text is highlighted as a different color from the surrounding text and is underlined, as shown in Figure.
15
Anchor Attributes:
Following are most frequently used attributes for <a> tag. href: specifies the URL of the target of a hyperlink. Its value is any valid document URL, absolute or relative, including a fragment identifier or a JavaScript code fragment. target: specify where to display the contents of a selected hyperlink. If set to "_blank" then a new window will be opened to display the loaded page, if set to "_self" then loads the new page in current window. By default its "_self", if set to "_name" then open the link in the window of that name. name & id: attributes places a label within a document. When that label is used in a link to that document, it is the equivalent of telling the browser to goto that label. event: attributes like onClick, onMouseOver etc. are used to trigger any Javascript or VBscript code. title: attribute lets you specify a title for the document to which you are linking. The value of the attribute is any string, enclosed in quotation marks. The browser might use it when displaying the link, perhaps flashing the title when the mouse passes over the link.
Internal Linking
Base Path for Links: It is not required to give a complete URL for every link. You can get rid of it if you will use <base> tag in your header. This tag is used to give a base path for all the links. So your browser will concatenate given relative path to this base path and will make a complete URL. For example we have used following base tag in all the pages at Ometasystems.com: <head> <base href="http://www.ometasystems.com/"> </head> So now if you will use <a href="/html/index.htm" then it will be considered as <a href="http://www.ometasystems.com/html/index.htm". In deciding what to use as the value of your href attribute, consider what type of link you want to use. Two basic types of links exist.
16
Absolute Links
Absolute links are those that include the entire pathname. In most cases, you use absolute links when linking to pages or sites that are not part of your own Web site. For example, if you are linking from your Web site to Yahoo!, you type http://www.yahoo.com as your link.
Relative Links
Relative links are called so because you dont include the entire pathname of the page to which you are linking. Instead, the pathname you use is relative to the current page. Relative links are most commonly used when you want to link from one page in your site to another. Heres an example of what a relative link might look like: <a href="contactme.html">Contact Me</a> This link looks for the contactme.html file in the same folder that contains this page. If you were linking to a file in another folder below the current one, the value of your href might look like this: <a href="wendy/contactme.html">Contact Me</a>
17
In this example, the phrase in between the opening and closing a tag is displayed in the Web page and labels the anchor as Section 1.
Link to an Anchor
To create the link to an anchor, you also use the a tag and the href attribute, as you would when creating any other type of link. To finish the link, you need to include a hash symbol (#) and the anchor name as the value of the href attribute.
18
If you need to create a link to a specific section with another page (not the one you are currently working on), then you use that pages filename and the anchor name separated by a hash mark (#), as in the following example. <a href="genealogy.html#intro">View names beginning with an "A" on our genealogy page.</a> In this case, the browser will first look for genealogy.html and then locate an anchor named intro on that page.
Target Windows
Have you ever visited a Web site and noticed that a second instance of the Web browser opened when you clicked a link? This happens when Web developers use the target attribute to load links in a browser window other than the one you are currently using. For example, you might want to offer visitors to your site a link to search Yahoo!, but you dont want to encourage them to leave your site. If you use _blank as the value of the target attribute in your link to Yahoo!, the browser will launch a new browser window to load http://www.yahoo.com.
19
Clicking this link in a browser causes the visitors e-mail program to launch. Then it opens a new e-mail message and places your e-mail address in the To: box of that message. Setting Link Colors: You can use three more attributes of the body tag to customize the three link colors of a Web page: normal link colors (link), visited link colors (vlink) and active link colors (alink). <body bgcolor="#ffffff" text="#000000" link="#003366" vlink="#999999" alink="#ff33cc">
Note: Default Link Colors: In most cases, the default link color for browsers is blue. The
default visited link color is purple, and the active link color is red. Remember, as with many other features of Web browsers, the user ultimately controls these default colors.
20
Image Preliminaries
So far in this book, you have created text-only Web pages. Theyre perfectly functional, but a bit dull. Web pages are more interesting and attractive when they include graphics. Much of the Webs popularity is due to its ability to present graphical content rather than only text, and even a few well placed graphics can make a huge difference in the look of a web page. Graphics of any size increase the time it takes to download a page, however, so you should use them with care to avoid making your pages awkward to access. Images appear on web pages in two ways: as part of the inline content or as tiling background images. Background images are added using background attribute in body tag or using Cascading Style Sheets. Inline images may be used on web pages in several ways: As a simple image. An image can be used on a web page much as it is used in print, as a static image that adds information, such as a company logo or an illustration. As a link. As we saw in the previous chapter, an image can be used as a link to another document by placing it in the anchor element. As an imagemap. An imagemap is a single image that contains multiple links (hotspots) that link to other documents. Well look at the markup used to add clickable areas to images in this chapter as well.
Which image format is suitable for you? The most common and most widely supported image file types are GIF: The Graphics Interchange Format (GIF) was the earliest format use in inline images on the Web. GIF format has the ability to encapsulate several images within one file, giving the format animation functionality. The GIF format has the following characteristics: Supports up to 8-bit color (256 colors) Supports transparency Is stored in a compressed, lossless format Can be interlaced and used for rudimentary animations JPEG: JPEG is the acronym for Joint Photographic Experts Group and it was created specifically for photographic imagery and shouldnt be used for flat-color graphics. JPEG is a commonly used method of lossy compression for digital photography (image). With JPEG, you get to keep all your colors, but you dont get to keep all the data about the image. Supports 24-bit color (64,000 colors) Does not support transparency Is stored using a lossy compression format; the smaller the file, the lower the quality of the Image. Can be stored in a progressive format
PNG: The Portable Network Graphics, or PNG format, was developed exclusively for the Web and is in the public domain. The PNG format takes advantage of a clever way of storing the information about the image so you dont lose color and you dont lose image quality; it is a lossless format. The only drawback is, because the standard is so new, only fourth-generation and later browsers support PNG graphics. The PNG format has the following characteristics: Supports 24-bit color (64,000 colors) Supports transparency Is stored using a lossless compression scheme Can be stored and displayed in interlaced format
21
The URL points to the location or address where the image is stored. The form of the URL may be either an absolute URL or a relative URL.
Therefore, you can help speed the display of your Web pages by telling the browser the sizes of your images right within the img tag. You do so with the height and width attributes.
22
In addition to the alt attribute, its a good idea to add the title attribute to your img tag. While the alt attribute specifies alternative text for images in case the images dont load, the title attribute can be added to images as well as links and other page elements. It serves as a quick tip for users to briefly explain the contents of the page element or, in this case, the image. The greatest benefit in using the title attribute is that its contents are displayed as tool tips in all browsers.
23
Dynamic HTML and Web Designing Positioning an Image on the Web Page
By default, the browser displays images inline. That is, it displays an image immediately to the right of the previous content. Text does not wrap around it. You can display an image on the left or right side of the Web page, however, allowing the surrounding content to flow around the image. This type of image is called a floating image. You create a floating image by using the <IMG> tag's ALIGN attribute. This is the same attribute you use to align the surrounding text with an
24
image. Table describes each value you can assign to this attribute.
Description Displays image on left side and surrounding flows around the image Displays image on right side of the window and surrounding flows around the image Table 7.3 Values for the ALIGN Attribute
25
26
27
Image Maps
Image maps allow you to specify several links that correspond to different areas of one single image, so that when users click different parts of the image they get taken to different pages. There are two types of image maps: Server-side image maps Client-side image maps
In the server-side image map, the user clicks on an image but the server must decode where the user clicked before the destination page (if any) is loaded. With client-side image maps, all of the map information, which regions map to which URLs can be specified in the same HTML file that contains the image. Including the map data with the image and letting the browser decode it. It has several advantages, including 1. There is no need to visit a server to determine the destination, so links are resolved faster. 2. Destination URLs can be shown in the status box as the users pointer moves over the image. 3. Image maps can be created and tested locally, without requiring a server or system administration support. 4. Client-side image maps can be created so that they present an alternative text menu to users of text-only browsers. Client-Side Image Maps using <map> and <area> In this, the image that is going to form the map is inserted into the page using the <img/> element as normal, except it carries an extra attribute called usemap. The value of the usemap attribute is the value of the name attributes on the <map> element, which you are about to meet, preceded by a pound or hash sign. The <map> element actually creates the map for the image and usually follows directly after the <img /> element. It acts as a container for the <area> elements that actually define the clickable hotspots. The <map> element carries only one attribute, the name attribute, which is the name that identifies the map. This is how the <img /> element knows which <map> element to use. The <area> element specifies the shape and the coordinates that define the boundaries of each clickable hot - spot.
Heres an example from the image map that was used for the image in Figure.
28
<html> <body> <p> It is an example of Image Map </p> <img src="ImageMap.gif" alt="Iamge Map" border=0 />
usemap="#gallery"
<map name="gallery"> <area shape="rect" coords="5,13,122,157" href="bike.html" target="_self"> <area shape="rect" coords="122,12,246,157" href="car.html" target="_self"> <area shape="rect" coords="6,159,121,294" href="book.html" target="_self"> <area shape="rect" coords="124,157,243,299" nohref="car.html" > </map> </body> </html> Advantages of Image Maps Since an image-map is one large image, you can place links in it the way you want without worrying about layout issues. Lesser HTML scripting is involved since there are programs available that will generate the code. Image map creation is quite simple if you use a program such as MapThis.
Disadvantages of Image Maps An image-map takes only one ALT attribute. Thus, it's not possible to have different ALT attributes for different links. Visitors with disability or those using text based browsers might not appreciate this. No interactivity is possible. You can't have separate mouseovers for individual links. An image map is one large image and if its not optimized properly, will take a long time to download.
29
Figure 6-1
Opening and closing table tags surround the entire section of code. This tells the browser that everything inside these tags belongs in the table. And there are opening and closing tr tags for each row in the table. These surround td or th tags, which, in turn, contain the actual content to be displayed by the browser.
Borders
Tables, by nature of their design, have internal and external borders. By default, most recent browsers set the border size to zero, making them invisible. However, borders can be quite
30
The frame Attribute To control which outside borders are displayed for a table, add the frame attribute to the opening <table> tag, and specify one of the values explained in Table 6-1.
The rules Attribute To control which inside borders of a table are displayed, add the rules attribute to the opening <table> tag, and specify one of the values explained in Table 6-2. Rules are the lines or borders around the individual cells. For example, to display only the horizontal borders within a table: <table border="5px" frame="box" rules="none">
31
Second, CellSpacing affects the amount of space between each of the cells in the table. While not located inside the actual cells, this space can be increased to allow for a gutter between multiple cells. <table border="5" cellpadding="5" cellspacing="15">
32
Figure 6-5
Cell Spanning
Tables that use a regular grid are useful for presenting data in a tabular format, but to lay out a page with tables, youll often need to remove some of the borders between rows and
33
<table border="1" cellspacing="2" cellpadding="4"> <tr> <td colspan="3">This cell spans all three columns.</td></tr> <tr> <td>Column 1</td> <td>Column 2</td> <td>Column 3</td> </tr> </table>
34
35
<table frame="void" rules="cols" > <tr> <td>Cell 1</td> <td>Cell 2</td> </tr> <tr><td>Cell 3 </td> <td>Cell 4</td> </tr> </table>
Dynamic HTML and Web Designing Group Cells by Rows and Columns
The frame and rules attributes of the <table> tag enable you to create many arrangements of borders in your tables. But if you need more flexibility, you can use rules="groups" to put borders only on specific groups of rows and columns.
36
37
38
39
This HTML code produces the table shown here, with the rules="groups" statement producing a vertical border between the groups of columns and no border between the columns that make up each group.
40
41
<html> <head> <title>Frames example</title> </head> <frameset cols="25%,75%"> <frame src="/html/top_frame.htm" /> <frame src="/html/main_frame.htm" /> <noframes> <body> Your browser does not support frames. </body> </noframes> </frameset> </html>
rows: attribute works just like the cols attribute and can take the same values, but it is used to specify the rows in the frameset. For example to create two horizontal frames, use rows="10%, 90%". You can specify the height of each row in the same way as explained above for columns. border: attribute specifies the width of the border of each frame in pixels. For example border="5". A value of zero specifies that no border should be there.
42
Targets
Imagine you have an HTML page for a frameset with two columns, called frameset_cols.html. The frames in this structure are called links on the left and intro on the right. When a user clicks the words About Us in the left frame, you want the About Us page to load in the right frame.
43
Accomplishing this task requires two steps. 1. Make sure the frame is named (using the name attribute), as in src="intro.html" name="intro" />in the frameset HTML document. <frame
2. Then, in the HTML page containing the link, use the target attribute in the a tag to specify in which frame the link should load. For example, <a href="page3.html" target="intro">.
Some particular values for the TARGET attribute have special meaning, which are summarized in Table. Value _self _blank _parent _top Description Loads the page into the current frame. Loads a page into a new browser window opening a new window. Loads the page into the parent window, which in the case of a single frameset is the main browser window. Loads a page into a new browser window, replacing any current frames.
Nested Framesets
You have seen that a single frameset gives you a fixed grid-like structure of rows and columns just like a table. If you want to create a more complex design, you might choose to use a nested frameset. You create a nested frameset by using a new <frameset>element in the place of one of the <frame> elements. Take a look at the following example:
<frameset rows=*, 300, *> <frame src=frames/top_frame.html /> <frameset cols=*, 400, *> <frame src=frames/blank.html /> <frame src=frames/main_frame.html /> <frame src=frames/blank.html /> </frameset>
44
This example creates a set of three rows. In the middle row is a nested frameset with three columns. You can see that the two side columns actually share the same file. Figure shows what this example looks like in a browser.
45
<HTML> <BODY> <H1 ALIGN="center">Floating Frame Example</H1> <IFRAME NAME="float1" SRC="fileone.htm" WIDTH="350" HEIGHT="200" ALIGN="LEFT"> There would be a floating frame here if your browser supported it. </IFRAME> <P>This is a simple example of how floating frames are used. Notice that in many ways the floating frame acts very similar to an inline image. </P> </BODY> </HTML>
Layers
The layer function enables the page designer to define precisely positioned, overlapping layers of transparent or opaque content in a page. Besides being able to stack layers on top of each other to create complex layouts, authors can bind the layers to code that can move them around or change the order of overlap. Scripting combined with absolute positioning can truly make pages more dynamic. The basic idea of a layer is similar to the idea of a frame, except that layers may overlap. They generally are defined in the same document, unlike frames, which require multiple documents. A layer defines a region or portion of the browser window that can be manipulated, and may overlap other layers. Layers come in two basic forms: 1. Positioned layers: Defined by the <LAYER> element 2. Inflow layers: Defined by the <ILAYER> element Positioned Layers To define a section of a document as a layer to position, enclose it within <LAYER> and </LAYER>. The layer should be named, just as a frame is named, so that it can be manipulated later. To name a layer, set the ID attribute of the element to a unique identifier. For a positioned layer, specify the upper corner of the layer by setting the TOP and LEFT attributes to the pixel coordinates of the upper-left corner of the layer, relative to the browser window. You may also want to set the WIDTH and HEIGHT attributes of the layer. These take
46
Inflow Layers Inflow layers are different than positioned layers, because inflow layers fall naturally within the flow of a document, much as an inlined object is positioned, such as an image. To indicate that content is part of an inflow layer, enclose it within <ILAYER> and </ILAYER> tags.
47
Browser Support The first Internet browsers had support for text only, and even the text support was limited to a single font in a single color, and little or nothing else. Then came web browsers with support for colors, fonts and text styles, and the support for pictures was added. The support for sounds, animations and videos is handled in different ways by different browsers. Some elements can be handled inline, some requires a plug-in and some requires an ActiveX control.
48
What Format to Use? The WAVE format is one of the most popular sound format on the Internet, and it is supported by all popular browsers. If you want recorded sound (music or speech) to be available to all your visitors, you should use the WAVE format. The MP3 format is the new and upcoming format for recorded music. If your website is about recorded music, the MP3 format is the choice of the future.
Like audio files, video files can be compressed to reduce the amount of data being sent. Because of the degree of compression required by video, most video codecs use a lossy approach that involves a trade-off between picture/sound quality and file size, with larger file sizes obviously resulting in longer download times. Video can be stored in many different formats. The AVI Format: The AVI (Audio Video Interleave) format was developed by Microsoft. The AVI format is supported by all computers running Windows, and by all the most popular web browsers. It is a very common format on the Internet, but not always possible to play on non-Windows computers. Videos stored in the AVI format have the extension .avi. The Windows Media Format: The Windows Media format is developed by Microsoft. Windows Media is a common format on the Internet, but Windows Media movies cannot be played on non-Windows computer without an extra (free) component installed. Some later Windows Media movies cannot play at all on non-Windows computers because no player is available. Videos stored in the Windows Media format have the extension .wmv. The MPEG Format: The MPEG (Moving Pictures Expert Group) format is the most popular format on the Internet. It is cross-platform, and supported by all the most popular web browsers.Videos stored in the MPEG format have the extension .mpg or .mpeg. The QuickTime Format: The QuickTime format is developed by Apple. QuickTime is a common format on the Internet, but QuickTime movies cannot be played on a Windows computer without an extra (free) component installed. Videos stored in the QuickTime format have the extension .mov. The RealVideo Format: The RealVideo format was developed for the Internet by Real Media. The format allows streaming of video (on-line video, Internet TV) with low bandwidths. Because of the low bandwidth priority, quality is often reduced. Videos stored in the RealVideo format have the extension .rm or .ram. The Shockwave (Flash) Format: The Shockwave format was developed by Macromedia. The Shockwave format requires an extra component to play. This component comes preinstalled with the latest versions of Netscape and Internet Explorer. Videos stored in the Shockwave format have the extension .swf.
49
50
51
52
Q.4 What is DHTML? Does working of DHTML depend on the type of browser we use? Explain. Ans. DHTML stands for Dynamic HTML. DHTML is the combination of HTML and JavaScript. DHTML is the art of combining HTML, JavaScript, DOM, and CSS. According to the World Wide Web Consortium (W3C): "Dynamic HTML is a term used by some vendors to describe the combination of HTML, style sheets and scripts that allows documents to be animated." DHTML is combination of several built-in browser features in fourth generation browsers that enable a web page to be more dynamic. Q.5 Define <BR> tag? Ans. Use the break tag to break lines. The format of the tag is as follows: <br>Text that appears on its own line. The <br> tag is special because, unlike so many other command tags, <br> has no corresponding end tag. The <br> tag is a stand-alone tag because it requests that the browser move down to the next line on the screen before displaying the text that follows. Q.6 Define HTML Headings. Ans. HTML headings are defined with the <h1> to <h6> tags. Headings Are Important: Use HTML headings for headings only. Don't use headings to make text BIG or bold. Search engines use your headings to index the structure and content
53
Q.9 How do we create tables in HTML? Explain with suitable example. Ans. Tables are defined with the <table> tag. A table is divided into rows (with the <tr> tag), and each row is divided into data cells (with the <td> tag). The letters td stands for "table data," which is the content of a data cell. A data cell can contain text, images, lists, paragraphs, forms, horizontal rules, tables, etc. Representing a table involves several kinds of HTML tags: TABLE tags, which surround the entire table specification an optional CAPTION element specifying the caption (name) of the table TR tags, which specify the table rows TH tags, which specify table row and column headers TD tags, which specify the data in the table, i.e. the contents of table cells.
Q.10 How to define an image in html document? Ans. HTML Images - The <img> Tag and the Src Attribute In HTML, images are defined with the <img> tag. The <img> tag is empty, which means that it contains attributes only, and has no closing tag. Attributes of the IMG element : ALIGN : Alignment of the image with respect to the text baseline. ALT : Text to use in place of the referenced image resource, for example due to processing constraints or user preference. SRC : Specifies the URI of the image resource. The URL points to the location where the image is stored.
54
Ans. HTML Unordered Lists: An unordered list starts with the <ul> tag. Each list item starts with the <li> tag. The list items are marked with bullets (typically small black circles). <ul> <li>Coffee</li> <li>Milk</li> </ul> How the HTML code above looks in a browser: Coffee Milk HTML Ordered Lists: An ordered list starts with the <ol> tag. Each list item starts with the <li> tag. The list items are marked with numbers. <ol> <li>Coffee</li> <li>Milk</li> </ol> How the HTML code above looks in a browser: 1. Coffee 2. Milk HTML Definition Lists: A definition list is a list of items, with a description of each item. The <dl> tag defines a definition list. The <dl> tag is used in conjunction with <dt> (defines the item in the list) and <dd> (describes the item in the list): <dl> <dt>Coffee</dt> <dd>- black hot drink</dd> <dt>Milk</dt> <dd>- white cold drink</dd> </dl> How the HTML code above looks in a browser:
55
<form action="/cgi-bin/mailinglist.pl" method="post"> Q.14 Describe any four input types you can use in a form on the web page. Ans. An HTML form is a document containing text content, markup, special elements called controls (checkboxes, radio buttons, menus, etc.), and labels on those controls. The control type defined by the INPUT element depends on the value of the type attribute: Text: To Creates a single-line text input control:<input type=text name=textbox1 value=/> Buttons: Authors may create three types of buttons: submit buttons, reset button and push buttons: Authors should specify the scripting language of a push button script through a default script declaration . Authors create buttons with the BUTTON element or the INPUT element. <input type=submit value=OK/> Checkboxes: Checkboxes are on/off switches that may be toggled by the user. A switch is "on" when the control element's checked attribute is set. When a form is submitted, only "on" checkbox controls can become successful. Several checkboxes in a form may share the same control name. Thus, for example, checkboxes allow users to select several values for the same property. The INPUT element is used to create a checkbox control. <input type="checkbox" name="Chechbox1" value="English" checked="checked" /> Radio buttons: Radio buttons are like checkboxes except that when several share the same control name, they are mutually exclusive: when one is switched "on", all others with the same name are switched "off". The INPUT element is used to create a radio button control.
56
The HTML frameset Element: The frameset element holds one or more frame elements. Each frame element can hold a separate document. The frameset element states HOW MANY columns or rows there will be in the frameset, and HOW MUCH percentage/pixels of space will occupy each of them. The HTML frame Element: The <frame> tag defines one particular window (frame) within a frameset. <frameset cols="25%,75%"> <frame src="frame_a.htm" /> <frame src="frame_b.htm" /> </frameset> Q.17 What is an Image Map ? Create a Image Map. Ans. Image maps allow you to specify several links that correspond to different areas of one single image, so that when users click different parts of the image they get taken to different pages. <html> <body> <p>Click on the sun or on one of the planets to watch it closer:</p> <img src="planets.gif" width="145" height="126" alt="Planets" usemap="#planetmap" /> <map name="planetmap"> <area shape="rect" coords="0,0,82,126" alt="Sun" href="sun.htm" /> <area shape="circle" coords="90,58,3" alt="Mercury" href="mercur.htm" /> <area shape="circle" coords="124,58,8" alt="Venus" href="venus.htm" /> </map> </body> </html> Q.18 What is HTML style sheets ? Ans. Web browsers have always had a standard set of styles such as paragraphs are divided by <P> tags and for heading tags <H1> through <H6> tags are used.. Styles enable Web authors to set the styles used for these standard tags, and create new tags with new formatting. A style is a set of formatting commands that dictate how text is formatted. Instead of adding a series of separate commands to text, you apply one style that contains all the commands. In HTML, a style sets specific formatting characteristics for tags on your
57
58
6. Can a data cell contain images? a) Yes b) No 7. a) b) c) d) 8. a) b) c) d) Each list item in an ordered or unordered list has which tag? list tag ls tag li tag ol tag Which of the following tags below are used for a multi-line text input control? textml tag text tag textarea tag Both b and c above
9. <meta> tag cannot be defined in the <head> tag. a) False b) True 10. Which of the following attributes below are used for a font name? a) fontname b) fn c) font d) face
59
20. <SCRIPT> </SCRIPT> tag can be placed within ________ A. Header B. Body C. both A and B D. none of the above
60
61
How would you create a table? Describe the process of (1) dividing the table into columns (2) giving header to the table columns (3) adding a border to a table (4) changing the color of a cell. Write short note on : (a) Explain text-tags with examples. (b) Audio support in Browser. image
Q.8
Q.9 What do you understand by an image map? What is the use of it? Explain. Q.10 Explain the procedure of creating a rectangular and a circular hotspot in an map using suitable examples. Q.11 Q.12 Q.13 Q.14 Q.15 Q.16
What do you mean by Cascading Style Sheets ? What are different techniques to embedding CSS into HTML pages ? Explain with example. Write short note on Frames &b Layers with examples. What do you understand about DOCTYPE in HTML? How Cell Padding is differ from Cell Spacing? How to link the Images with in HTML? How we define Src Attribute and Alt Attribute in HTML? How you understand about Forms output? How you use Forms Action Attribute and Submit Button in HTML?
Q.17 What are the Hyperlink,Anchors and Link in the HTML? Q.18 How to use Line Break and Horizontal Line tags in HTML? Q.19 Q.20 What are Style Sheets? What are the style precedence rules when using multiple approaches? What are Core Attributes and Core Events in HTML ?