![]() |
Intro Browser The Page Tags Elements Tables Layout Perfection
|
|
Of course, you want more than just text in your web pages, even if you can make it in cool colors. You want lightning and thunder... or at least, some pictures and audio.
The text that you've written is an actual part of your HTML page, but graphics and audio are separate and may even be located somewhere else in the world. To get them to appear (or sound), you have to call them.
<IMG SRC="http://URL_address/filename.jpg">Here is the basic "call" that you use to get a picture into the page. Note that it's a command, not a tag, so there's no close. The parts are IMG (the type of element you are calling), and SRC="URL/filename.type" (the full name of the image, and the address where it is located). When your HTML page is being rendered by the browser, it sees the address and sends a call to that server to fetch the file. If the picture is located in the same directory as the HTML page (in other words, it's been uploaded to your home page directory), you can just call it by file name and don't have to put the full address. If it's in a directory that's close to the HTML page, you'll need to include the relative path in the file name. For example, at Net4TV we store our images in a "graphics" directory that's inside the directory where our HTML files are located, so our image calls usually look like <IMG SRC="graphics/filename.jpg">. Just as tags can have attributes that extend them, so can your element commands. If you know the height and width (in pixels) of your image, you can add these as an attribute and your page will load faster (the browser will "block in" the space for the image and render the rest of the page while the image is coming in). You can align your image to one side or the other of the page, and add a border. Here's the actual call used to place our pipe smoker (above) into this page: <IMG SRC="graphics/pipe.jpg" height=215 width=200 align=right border=2>
What do you think would happen if you used different values in the "height" and "width" attributes than the actual picture size? This picture is exactly the same as the picture above, except that it is set height to 86 and its width to 80 and the browser scales it automatically. What makes this super cool is that the page only fetches the graphic one time. Once it's come in, it can be used a lot of different ways without any cost in loading time:
It's a separator bar at height=10 and width=350! (And now you know how we did our "Zen" separator.) <A HREF="http://URL/filename.mid">Click here to play a MIDI.</A> Other common digital audio formats, like .WAV and .AU, work the same way but are generally "heavier" (bigger data size) than MIDI so they take longer to load. If you want your sound to play automatically when your page loads, there are a couple of different approaches depending on the browser that will display the page. WebTV and Microsoft Internet Explorer both support the <BGSOUND> command. The command syntax is very much like an IMG command: <BGSOUND SRC="URL/filename.type">You can extend the BGSOUND command with the LOOP attribute, if you wish. The values can be LOOP=1 (or any number), or LOOP=INFINITE. (Netscape Navigator doesn't recognize the BGSOUND command, so if you want to include a background sound for Netscape users, you have to use an <EMBED SRC="URL/filename.type"> tag, with attributes of HIDDEN=YES and AUTOSTART=TRUE.) Getting a picture into your background, or a specific background color, is not done by a command or a tag, but by attributes in the page's <BODY> tag. For background color, use the attribute BGCOLOR="colorname"; for a background image, use BACKGROUND="URL_address/filename.type". Here's the BODY tag for this page that displays the ricepaper backgound: <body background="graphics/ricegray.gif">One thing that you should think about as you call elements into your pages: every time you call an image or audio, the browser has to open a connection to the server where it resides to call it, just like it does when you load a web page. If all of your elements are on the same server as your web page (for example, your page and all of your graphics are on Tripod), everything will start to load in as soon as the first connection is established. But since WebTV can't upload, a lot of users call audio clips and many images into each page from servers all over the Net. This isn't a good idea for several reasons:
Dudette |