Sams Teach Yourself HTML 4 in 24 Hours
- Table of Contents
- Copyright
- About the Author
- Acknowledgments
- Tell Us What You Think!
- Put Your HTML Page Online Today
- I. Your First Web Page
- Hour 1. Understanding HTML and XML
- Hour 2. Create a Web Page Right Now
- Hour 3. Linking to Other Web Pages
- Hour 4. Publishing Your HTML Pages
- II. Web Page Text
- Hour 5. Text Alignment and Lists
- Hour 6. Text Formatting and Font Control
- Hour 7. Email Links and Links Within a Page
- Hour 8. Creating HTML Forms
- III. Web Page Graphics
- Hour 9. Creating Your Own Web Page Graphics
- Hour 10. Putting Graphics on a Web Page
- Hour 11. Custom Backgrounds and Colors
- Hour 12. Creating Animated Graphics
- IV. Web Page Design
- Hour 13. Page Design and Layout
- Hour 14. Graphical Links and Imagemaps
- Hour 15. Advanced Layout with Tables
- Hour 16. Using Style Sheets
- V. Dynamic Web Pages
- Hour 17. Embedding Multimedia in Web Pages
- Hour 18. Interactive Pages with Applets and ActiveX
- Hour 19. Web Page Scripting for Non-Programmers
- Hour 20. Setting Pages in Motion with Dynamic HTML
- VI. Building a Web Site
- Hour 21. Multipage Layout with Frames
- Hour 22. Organizing and Managing a Web Site
- Hour 23. Helping People Find Your Web Pages
- Hour 24. Planning for the Future of HTML
- VII. Appendixes
- A. Readers' Most Frequently Asked Questions
- B. HTML Learning Resources on the Internet
- C. Complete HTML 4 Quick Reference
- D. HTML Character Entities
Margins, Borders, and Scrolling
The problem with the nine-frame arrangement in Figure 21.5 is that it looks ugly and stupid. We can fix that.
The ugly parts are the gray dividers between the frames, which completely ruin the effect of surrounding the center frame with nicely designed graphics. There also isn't enough room in the top and bottom frames to display the graphics without scrollbars. Fortunately, there are HTML commands to get rid of the frame dividers, make more space in small frames by reducing the size of the margins, and force frames not to have scrollbars.
Before you read about these HTML magic tricks, take a look at the dramatic results they can achieve. Figure 21.10 is a nine-frame window displaying the same Web pages shown in Figure 21.5. Obviously, Figure 21.10 looks much nicer! In Figure 21.9, you can see the anti-ugliness medication I gave to the frameset code from Figure 21.6.
Figure 21.9 Like Figure 21.5, this is actually nine separate Web pages being displayed in nine frames.
Figure 21.10 This is the frameset document shown in Figure 21.9. By adding some attributes to the <frame /> tags, I was able to make the frames look much nicer.
In addition to the name attribute, the <frame /> tag can take the following special frame-related attributes:
- marginwidth Left and right margins of the frame (in pixels).
- marginheight Top and bottom margins of the frame (in pixels).
- scrolling Display scrollbar for the frame? ("yes" or "no")
- frameborder Display dividers between this frame and adjacent frames? (1 means yes, 0 means no)
- noresize Don't allow this frame to be resized by the user.
marginwidth and marginheight are pretty self-explanatory, but each of the other attributes is discussed in detail in the next few paragraphs.
Normally, any frame that isn't big enough to hold all of its contents will have its own scrollbar(s). The top and bottom frames in Figure 21.5 are examples. If you don't want a particular frame to ever display scrollbars, you can put scrolling="no" in the frame tag. Conversely, scrolling="yes" forces both horizontal and vertical scrollbars to appear, whether they are needed or not.
People viewing your frames can ordinarily resize them by grabbing the frame border with the mouse and dragging it around. If you don't want anyone messing with the size of a frame, put noresize in the <frame /> tag.
Both Microsoft Internet Explorer and Netscape Navigator allow you to control the size of the frame borders or eliminate the borders altogether. This makes a frame document look just like a regular Web page, with no ugly lines breaking it up.
Unfortunately, you need to use three different sets of HTML tags for maximum compatibility:
- For Microsoft Internet Explorer 3, you can make the borders disappear by including frameborders="no" in the <frameset> tag.
- For Netscape Navigator and Microsoft Internet Explorer 4, use border="0" in the <frameset> tag to eliminate borders, or border= followed by a number of pixels to change the size of the frame borders.
- If you want borderless frames to show up in all recent versions of both popular browsers, type frameborders="no" border="0" in your <frameset> tag.
Guess what? The official HTML 4 standard actually specifies yet another method for eliminating frame borders. To be compatible with that standard, you need to put a frameborder="0" attribute in every single <frame /> tag—not just in the <frameset> tags. This doesn't have any effect in any existing browser, but it's a good idea to include it now to avoid future compatibility problems.
The frameset document in Figure 21.10 uses all these methods, just to be thorough. I recommend you do the same.
When used together with custom graphics, borderless frames can allow you to create sites that are easier to navigate and more pleasant to visit. For example, when someone visits the site in Figure 21.10 and clicks one of the navigation choices in the bottom frame, the page he chose comes up in the middle frame quickly because the title graphic, navigation buttons, and border graphics all remain in place. The frames also automatically adapt to changes in the size of the browser window, so the nice "picture frame" effect looks just as good at 1,024x768 resolution as it does at 640x480.
Figure 21.11 shows the result of clicking the "Facts & Forecasts" link in Figure 21.10. Note that the middle frame gets its own scrollbar whenever the contents are too big to fit in the frame.
Figure 21.11 Clicking a link at the bottom of Figure 21.10 brings up a new page in the middle frame, without redrawing any of the other frames.
Summary | Next Section

Account Sign In
View your cart