HTML, XHTML and CSS All-In-One for Dummies - Andy Harris [130]
5. Change content’s left attribute to 20 percent.
Because content has relative positioning, setting the left to 20 percent will add 20 percent of the parent element to each content’s left value. This will ensure that there’s room for the menu to the left of all the content panes.
6. Give content a width property.
If you don’t define the width, content panels may bleed off the right side of the page. Use the width property to ensure this doesn’t happen.
Determining Your Layout Scheme
All these layout options might just make your head spin. What’s the right strategy? Well, that depends.
The most important thing is to find a technique you’re comfortable with that gives you all the flexibility you need.
Absolute positioning seems very attractive at first because it promises so much control. The truth is, it’s pretty complicated to pull off well, it isn’t quite as flexible as the floating layout techniques, and it’s hard to make it work right in older browsers.
Floating layouts are generally your best bet, but it’s good to know how absolute positioning works. Every once in a while, you find a situation where absolute positioning is a good idea. You see another example of absolute positioning in Chapter 7 of Book IV: animating the position of an element on the screen.
Sometimes, fixed and relative positioning schemes are handy, as in the example introduced in the preceding section.
Sometimes, you’ll find it’s best to combine schemes. (It’s difficult to combine absolute positioning with another scheme, but you can safely combine floating, fixed, and relative positioning techniques most of the time.)
There really aren’t any set answers. CSS layout is still an art in progress, and there’s plenty to find out about that I can’t describe in this book. Keep practicing and keep exploring, and you’ll be building beautiful and functional layouts in no time.
Book IV
Client-Side Programming with JavaScript
JavaScript code adds interactivity for checking input and even making games and animations.
Chapter 1: Getting Started with JavaScript
In This Chapter
Adding JavaScript code to your pages
Setting up your environment for JavaScript
Creating variables
Inputting and outputting with modal dialogs
Using concatenation to build text data
Understanding data types
Using string methods and properties
Using conversion functions
Web pages are defined by the XHTML code and fleshed out by CSS. But to make them move and breathe, sing, and dance, you need to add a programming language or two. If you thought building Web pages was cool, you’re going to love what you can do with a little programming. Programming is what makes pages interact with the user. Interactivity is the “new” in “new media” (if you ask me, anyway). Learn to program, and your pages come alive.
Sometimes people are nervous about programming. It seems difficult and mysterious, and only super-geeks do it. That’s a bunch of nonsense. Programming is no more difficult than XHTML and CSS. It’s a natural extension, and you’re going to like it.
In this chapter, you discover how to add code to your Web pages. You use a language called JavaScript, which is already built into most Web browsers. You don’t need to buy any special software, compilers, or special tools because you build JavaScript just like XHTML and CSS — in an ordinary text editor or a specialty editor such as Aptana.
Working in JavaScript
JavaScript is a programming language first developed by Netscape Communications. It is now standard on nearly every browser. You should know a few things about JavaScript right away:
♦ It’s a real programming language. Don’t let anybody tell you otherwise. Sure, JavaScript doesn’t have all the same features as a monster, such as C++ or VB.NET, but it still has all the hallmarks of a complete programming language.
♦ It’s not Java. Sun Microsystems developed