So, You Want a Background, Huh?
[Adding Styles] [Text Tool Tips]
[Affecting Images -- New Event Handlers!]
[For Search Engines]
This piece is the first in, I hope, a long series of HTML 4.0 tutorials. If you haven't already, it would be best if you read over my
HTML 4.0
reference tutorial. It offers a general overview of the new flags and attributes involved with the latest version of HTML to hit the Net.
Now it's time to get a little more specific about what you can and cannot do with this version. We'll start with a brand new flag, SPAN. If you haven't seen or heard about it by now, get ready. This pup will be one of the big workhorses in Web pages to come.
| Please note: The SPAN flag is not in full use across all browsers yet. The Internet Explorer 4.0 (or better) browser will support all of the attributes listed below. Netscape Navigator 4.0 (or better) will support the SPAN flag as long as it's dealing with text, except for the TITLE attribute (as of 11/23/98). The examples below that use images will not function. |
SPAN: What Does It Do?
Nothing! Not a darn thing. But that's the beauty of it. Above all, remember this about HTML 4.0: Cascading Style Sheets (CSS) will be big. See So, You Want Cascading Style Sheets, Huh? . The use of one command to denote multiple points on a page is the wave of the HTML future.If you've used CSS, you know that you've always had the ability to attach a style to a command. For instance, you could say that every time the BOLD flag is used, also make the text Arial and blue, right? You also probably know that you could stick style commands into other flags. You could put:
...into just about any flag and the text modified by the flag would also carry the CSS effect.
But in all cases, you still had to use a flag that itself would affect the text, the image, or whatever. That's where the SPAN flag comes in so handy. It doesn't affect the text at all. It is there only to carry with it other attributes to affect the text, the image, or whatever.
In fact, the text in this paragraph is surrounded by the <SPAN> and </SPAN> commands. Really. Look at the source code if you don't believe me. See? No effect.
Now, before someone writes to me telling me that you can get the same effect using just the <FONT> and </FONT> commands in place of <SPAN>, yes, that's true. But what you're doing is using a flag for something it isn't meant to do. Plus, the SPAN flag is an HTML 4.0 entity and will thus comprehend HTML 4.0 attributes.
| <STYLE TYPE="text/css"> .newtext {font-size: 18pt; color: #ff0000; font-family: arial} </STYLE> |
There's both a Class (with the leading dot) and an ID (with the leading #) there to be used. And use them we shall.
- Using the Class:
- Follow this Format:
<SPAN CLASS="newtext">Here's What You Get</SPAN> - Here's What You Get
- Follow this Format:
- Using the ID:
- Follow this Format:
<SPAN ID="newtext2">Here's What You Get</SPAN> - Here's What You Get
- Follow this Format:
Text Tool Tips
This is really where the SPAN flag shines. This is also how I see the command being used most around the Net today.SPAN will allow a TITLE attribute that shows up on the page when the mouse is left to sit on the text. It looks a lot like what the ALT command (See So, You Want Faster Loading Pages, Huh? ) produces when used with an image. Take a look. Lay your pointer on the text "Here's What You Get" below.
- Adding the Title Tool Tip:
- Follow this Format:
<SPAN TITLE="This is the tool tip box">Here's What You Get</SPAN> - Here's What You Get
- Follow this Format:
That's very cool. I would use it to death. Here's the code that made it: If you've read any of the Goodies' image flip tutorials, you can probably pick this one apart. Pretty basic, huh? The only other fancy thing I want to point out about the format above is that I have the onMouseOut set to the same image as the one the image command calls for. See that? That way it returns the image to its original state when the mouse moves off. *Yawn,* you say. You've seen it all before. Well, try this on for size. Below is the same black box image. Lay your pointer on it, click and hold, then release the click. Then double click. Okay, admit it. That was really smooth. It was done with some new Event Handlers that the SPAN flag understands. Here's the code: The format of calling for the images is the same, but let me point out those new commands: Let me hit you with a couple more. They may work or they may not. These are three new specifically HTML 4.0 level Event Handlers. Click on the box below and press any key on the keyboard. Anything? I didn't get the effect when I tried it. Later level browsers will though once HTML 4.0 becomes the standard all the way around. Here's the code: You can probably guess what each of them do. Here are the Event Handlers above and one more you'll soon be concerned with. LANG is an attribute that tells the search engine what language is being used inside the SPAN flags. It looks like this: The 4.0 recognized codes are ar (Arabic), de (German), el (Greek), es (Spanish), fr (French), he (Hebrew), hi (Hindi), ja (Japanese), it (Italian), nl (Dutch), pt (Portuguese), ur (Urdu), ru (Russian), sa (Sanskrit), zh (Chinese). Enjoy!
Affecting Images
Not only will the SPAN flag act as a vehicle to carry Style Sheet commands, but it will also accept JavaScript Event Handlers. It actually makes a heck of an image flip (see
So, You Want An Image Flip, Huh? (Part 2)
.) Roll your mouse over this image:
<SPAN onMouseOver="document.pic1.src='blueone.gif'"
onMouseOut="document.pic1.src='blackone.gif'">
<IMG SRC="blackone.gif" height="50" width="150" name="pic1">
</SPAN>
<SPAN onMouseDown="document.pic2.src='/blueone.gif'"
onMouseUp="document.pic2.src='/redone.gif'"
onDblClick="document.pic2.src='/greenone.gif'">
<IMG SRC="/blackone.gif" height="50" width="150" name="pic2">
</SPAN>
~Know this, too~
This would be best if you surrounded a division of the page with the SPAN flag.
<SPAN onKeyDown="document.pic3.src='/blueone.gif'"
onKeyUp="document.pic3.src='/redone.gif'">
<IMG SRC="/blackone.gif" height="50" width="150" name="pic3">
</SPAN>
~and~ For Search Engines
Again, if you've read the
HTML 4.0
overview, you'll already have a head start on what these last two attributes do. DIR and LANG are specifically for search engine use. They won't affect the look of your page at all.
DIR denotes direction. There are languages that do not move from left to right like English. Some go right to left, and if you live in a country where you read right to left, then the English left-to-right seems strange. Still with me?
By using the DIR command, you can tell the search engine that this blurb of text between the SPAN flags is going a specific way. Right to left is "RTL," while left to right is "LTR." It looks like this:
Yes, there is also a code set aside if you wish to denote a language that doesn't really exist, like Pig-Latin or Klingon. Follow the same format as above, except add x- before the name. Like so: LANG="x-ubbee dubbie." The "x" means it's an experimental language. If someone else on the Net has registered that same kind of language, maybe you two nutty kids can get together. That's That
This SPAN flag is going to be big on the Web. It's just a great idea that does so much. And now you've seen every aspect and attribute it'll hold.
I'd start using it straightaway with text. Those with the right browser will get the effect, those that don't, won't. But they'll be none the worse for wear by your having it there for others to enjoy.
I don't know if I'd start using SPAN with images quite yet, especially if the Event Handler is a necessary part of the page. Go with JavaScript until HTML 4.0 is standard across the board.
[Adding Styles] [Text Tool Tips]
[Affecting Images -- New Event Handlers!]
[For Search Engines]
