22.04.2013 Views

HTML, XHTML & CSS

HTML, XHTML & CSS

HTML, XHTML & CSS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

52<br />

Part III: Taking Precise Control Over Web Pages and Styles<br />

browser window. Thus, instead of letting it be drawn automatically to the<br />

right of the navigation bar, you can place an image down and to the left, as<br />

in Figure 10-3. But absolutely positioned items always percolate to the top<br />

layer when items overlap, which is why Pixel’s picture shows up on top. We<br />

change this default order later in the chapter.<br />

#theCat {position: absolute; top: 120px; left: 107px;}<br />

Figure 10-3: The image is more striking in this<br />

location.<br />

You might be wondering why the navbar rule (defined in the listing in the<br />

earlier section, “Visual layouts”) and the theCat rule (in the code snippet<br />

immediately preceding Figure 10-3) both start with a pound symbol<br />

(also known as a hash mark or octothorpe). That’s because the pound<br />

symbol applies to an id attribute. You use a period to start a class rule,<br />

and it will apply to every instance of that class wherever it appears on a<br />

page. Thus, although you can apply either a class or an id to specific<br />

elements, the difference between these two is that a class can be used<br />

repeatedly. Comparatively, an id can appear only once on a page. You<br />

can’t have anything else on the page that uses theCat as its id. The difference,<br />

quite simply, is that a class lets you refer to every instance of some<br />

(X)<strong>HTML</strong> element with a single reference, but an id can address only a<br />

single instance for an element.<br />

Overlapping<br />

Two objects can be assigned to the same position in a Web page. Although<br />

this may sound like a problem, overlap can produce interesting design

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!