• Simple Solutions
  • How We Make it Simple
  • About Us

Simple Solutions

We offer a range of services designed to get veterinary professionals online and to keep their web site current. Every one of our services is developed specifically for the veterinary profession, and is designed to be simple to use. Learn More »

How We Make it Simple

We make working with us simple by simply understanding your needs. We focus exclusively on the veterinary profession and provide services that are simple and effective. We also back our services with awesome customer support and the best guarantee in web design. Learn More »

About Us

We speak your language. Established in 2001, veterinary web site design and development is what we do. Our focus is on providing simple, high quality services - without the techo-speak and attitude! Learn More »

Design Primer 5: Styles and Divs

So divs were mentioned in Part 3 and then there's been nothing on them yet. What's up with that? Good question - we'll have a bit of fun with divs here.

The Purpose of Divs

Divs allow us to divide web pages into sections, enabling us to apply styles to all the content in the div by just adding a style to that div.

We'll do a simple example (we'll use embedded style sheets for simplicity's sake, but this will work just as well with an external style sheet).

Example: Simple Div Styling

<html>

<head>

<title>Divs Are Fun!</title>

<style type="text/css">

h1 { color: red; }

.pageTop { color: green; font-size: 15pt; }

.pageBottom { color: blue; font-size: 10pt; }

</style>

</head>

<body>

<h1>Using Divs!</h1>

<div class="pageTop">

<p>This paragraph is in the top div.</p>

<p>So is this one.</p>

<p>And this one!</p>

</div>

<div class="pageBottom">

<p>This paragraph is in the bottom div</p>

<p>Also in the bottom div</p>

</div>

</body>

</html>

Web Site Screen Shot

See how all the paragraphs in a div have the same style? We didn't even need to include p in our style sheet.

Now for some real fun - we'll get into moving the divs around the page for different layouts. Ready? Let's do it! So we can see what's happening, we'll add a border around the divs and give them a fixed width (otherwise they are as wide as the web page).

Example: Positioning Divs

<html>

<head>

<title>Divs Are Fun!</title>

<style type="text/css">

h1 { color: red; }

.pageTop { color: green; font-size: 15pt; position: relative; top: 40px; left: 100px; }

.pageBottom { color: blue; font-size: 10pt; }

div { border: 1px solid red; width: 300px; }

</style>

</head>

<body>

<h1>Using Divs!</h1>

<div class="pageTop">

<p>This paragraph is in the top div.</p>

<p>So is this one.</p>

<p>And this one!</p>

</div>

<div class="pageBottom">

<p>This paragraph is in the bottom div</p>

<p>Also in the bottom div</p>

</div>

</body>

</html>

Web Site Screen Shot

Cool, huh? Here is what happened:

  • The top div has moved 40 pixels down and 100 pixels to the right (top: 40px; left: 100px; inserted 40 pixels above and 100 pixels left of the div, pushing it down and to the right)
  • The divs are outlined and have a width of 300 pixels because we added the div { border: 1px solid red; width: 300px; }
  • The position: relative tells Internet Explorer to move the top div starting from where it would appear on the screen normally. As a result, the two paragraphs actually overlap one another
    • If we had used position: absolute, it would position the top div 40 pixels to the right and 100 pixels below the top-left corner of the screen. Try it for yourself:

Example: Absolute Positioned Divs

<html>

<head>

<title>Divs Are Fun!</title>

<style type="text/css">

h1 { color: red; }

.pageTop { color: green; font-size: 15pt; position: absolute; top: 40px; left: 100px; }

.pageBottom { color: blue; font-size: 10pt; }

div { border: 1px solid red; width: 300px; }

</style>

</head>

<body>

<h1>Using Divs!</h1>

<div class="pageTop">

<p>This paragraph is in the top div.</p>

<p>So is this one.</p>

<p>And this one!</p>

</div>

<div class="pageBottom">

<p>This paragraph is in the bottom div</p>

<p>Also in the bottom div</p>

</div>

</body>

</html>

Web Site Screen Shot

Now the top div overlaps the web page heading as well. Crazy stuff, eh? There's lots more you can do with CSS, but that's beyond our scope for today. That's it for CSS: you now know the basics. Good job! All that's left is to introduce you to some common styles and their usage in the CSS Quick Reference article (a good place to refer back to when starting out!).

Bionex Dog

Web Site Maintenance Packages Now Available

We are pleased to announce the launch of our new Bionex Web Site Maintenance Packages. These great packages give you both a significant discount off our regular maintenance rates, priority status on updates, and the freedom to request updates to your web site every month..

Web Site Maintenance Packages make it easy to keep your web site up to date. Learn More »

Satisfied Customers

"I VERY MUCH appreciate all that you are doing for me. It has made such a difference to have you on my websites. Thanks."

More Testimonials »