The Incredibly Useful DIV Tag

November 20, 2001, 01:00 AM —  ITworld — 

Hello! As always, thanks for reading. This week, we're going to talk a
little about a tag I haven't spent much time talking about, but which I
use almost every day. The

tag, or division tag, has no real
properties of its own, but it can be almost infinitely useful as a
holding tag. The DIV tag can make naming and placing HTML, CSS, and
DHTML elements a snap.

First off, imagine you want to create a Web page with some text and
graphics, and you'd like to put it all together in a way that's not too
offensive to the eye. A very understandable, and hopefully achievable
goal! And as we've discussed in earlier newsletters, there are a few
ways to do this.

Setting up your page in a table
Within a table, you can place the text on the left and graphics on the
right, or vice versa. Or you could mix it up a little by placing images
throughout the page and interspersing text as you go. You could
actually end up with something that looked quite nice.

Framing your elements
By dividing the page into two halves, with one frame for each half, you
can then use an HTML document with your text for the left half and an
HTML document with your images for the right half. You could also make
this more complicated as well by adding additional frames, mixing up
text and graphics in your HTML docs, etc.... Frames are a good way to
make an interesting looking page, and many designers have done great
work using frames for page layout.

But let's say you want something different. You want your text to
overlap your images in some places, and you even want your images to
overlap your images. You want to be able to make visual changes to the
layout of your page by simply changing a number, not reworking large
blocks of code. This is, of course, possible. And if you've been
reading along for a while, you may remember my series on Cascading
Style Sheets (http://www.itworld.com/nl/html_tutor/06262001), and how
they can be used to do exactly this.

The trick, if you remember, was to add the STYLE attribute to your
image and anchor tags. Setting the parameters of this attribute allowed
us to place images and text anywhere on a page. The only problem is,
when you're constructing a page with plenty of elements -- many
different images and even animations -- plus diverse blocks of text and
links, you can end up with some pretty messy code.

Enter the DIV tag
As stated above, DIV stands for division. Technically, the DIV tag
merely sets an HTML element apart from other HTML elements. It's sort
of like having separate cubby-holes for each of your Web page's pieces
with a separate DIV tag naming each individual part. The neat thing is,
you can then add the STYLE attribute right into the DIV tag,
eliminating the need to add it to the image or anchor tag. Also, the
division tag

I like it!
Post a comment
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
Resources
White Paper

Symantec Backup Exec 12 and Backup Exec System Recovery 8 deliver industry leading Windows data protection and system recovery. Download this whitepaper to find out the top reasons to upgrade and how to get continuous data protection and complete system recovery.

Webcast

Data and system loss — from a hard drive failure, malicious attack, natural disaster, or simple human error — can happen anytime. Don’t leave your business vulnerable. Make sure you have a secure recovery strategy in place. Symantec's latest backup and system recovery technology can efficiently restore critical applications, individual emails and documents and even restore your entire system in minutes in the event of a loss.

White Paper

Businesses face a growing challenge to ensure that the IT environment is properly protected. Backup Exec 12 integrates with other applications in the Symantec family of products, to complement your current data protection strategy, keep your data securely backed up and make it recoverable when you need it most.

Free stuff

Enterprise 2.0 Implementation
By Aaron C. Newman, Jeremy Thomas
Published by McGraw-Hill
Learn more!

Deploying Cisco Wide Area Application Services
By Zach Seils, Joel Christner
Published by Cisco Press
Learn more!

Featured Sponsor

AISO founders envisioned a Web hosting company that was environmentally friendly. While the company employed energy-efficient innovations like solar panels, its infrastructure produced unacceptable power and cooling requirements. Find out how AISO leveraged AMD technology to overcome their challenge in this case study white paper.

In this whitepaper, Scalar explores the opportunity to change the landscape with respect to mission critical databases built around Oracle. Leveraging technologies such as Linux, high-end commodity processing power and Oracle RAC technology to architect, design, build and maintain database infrastructure that delivers maximum availability, reliability and performance at a fraction of traditional cost.

On a typical day, weather.com, the Web site for The Weather Channel in Atlanta, serves up between 15 million and 20 million page views. But in September 2004, when back-to-back hurricanes ransacked Florida, the peak traffic on one day more than tripled: over 70 million page views by more than 7 million unique visitors. Read the full success story now.

More Resources