Need a new web host or having a problem with a script? Tips and advice on the best way to design, build and maintain your most valuable asset - your website!

Can you have too many Divs in your code?

rlunatunes
Posts: 31
Joined: 20 Feb 07
Trust:

Can you have too many Divs in your code?

I was told that you can have too many divs in your code....Is that true.

This next question may be silly but.......what is a div?

I seem to have pretty many in my source code :)

Thanks,
Randy
  • 0
[url=http://mozy.com/?ref=3f9a896b&kbid=26059&m=8":1uga1vcr][color=red:1uga1vcr]Mozy Unlimited Backup....Excellent Computer Backup Service!!! "$4.95/month"[/color:1uga1vcr][/url:1uga1vcr]
 
PremiumMember
chatyak86
Posts: 1085
Joined: 17 Jun 06
Trust:
The <div> tag in XHTML is a tag that defines logical divisions within the content of a page. What this means is that a <div> tag defines sections of a Web page to make it easier to manage, style, and manipulate.


^^^^^
Straight from about.com although that is all true...

Basically you can set divs on the page and style each section differently using CSS.... I use divs when I want different chunks of text to look different etc..

I never heard about having too many........ whoever said that must have a TON on their page.
  • 0
rlunatunes
Posts: 31
Joined: 20 Feb 07
Trust:
I do have the divs with position absolute and z-index as Mark talks about in
this thread:

https://www.affilorama.com/members/forum ... hlight=div

And I guess thats not a good thing:(

Randy
  • 0
[url=http://mozy.com/?ref=3f9a896b&kbid=26059&m=8":1uga1vcr][color=red:1uga1vcr]Mozy Unlimited Backup....Excellent Computer Backup Service!!! "$4.95/month"[/color:1uga1vcr][/url:1uga1vcr]
 
PremiumMember
chatyak86
Posts: 1085
Joined: 17 Jun 06
Trust:
You mean absolute positioning. There is nothing wrong with that but it will show up wrong on some browsers I bet you. That is why I use tables.
  • 0
rlunatunes
Posts: 31
Joined: 20 Feb 07
Trust:
Adrian,
I'm using text frames for my text. Would it be better to use tables for my text also??

Randy
  • 0
[url=http://mozy.com/?ref=3f9a896b&kbid=26059&m=8":1uga1vcr][color=red:1uga1vcr]Mozy Unlimited Backup....Excellent Computer Backup Service!!! "$4.95/month"[/color:1uga1vcr][/url:1uga1vcr]
 
PremiumMember
chatyak86
Posts: 1085
Joined: 17 Jun 06
Trust:
Text frames? Do you mean an I-frame? Personally I would stay away from any kind of frame lol

I recommend using a table yes. They are supported 99.9%
  • 0
PremiumMember
sean06
Posts: 1004
Joined: 16 Jun 06
Trust:
Yeh, when it comes to SEO, frames aren't a very good way to go. Better off using tables like Adrian said. Can you think why frames might not be good for SEO purposes?
  • 0
www.SixDayWeekend.com
Free Training Videos reveal how I make 6 figures while travelling the world
 
Site Admin
markling
Posts: 2071
Joined: 13 Jun 06
Trust:
Hey Randy,

I think of a DIV as like a box. It can contain text or images, and when you tell it to do things (like "get thee hence to the other side of the page") it takes everything inside it as well, just like a box.

People use DIVs in much the same way that they use tables: You can put a border around a div, you can make it float to the left or the right, you can use it to put your content in a nice shaded box so that it stands out from other text, and you can say things like "all text inside this box should be 20px red Verdana" using CSS.

In that post you referenced, I mentioned that DIVs don't behave the same way across different browsers IF you don't specify a doctype. That's a load of gobbledigook if you're not a webgeek. Basically, people still use tables (<TABLE><TR><TD></TD></TR></TABLE> etc) because the browsers still haven't agreed on how to interpret the sizing of DIVs. So if you say "I want this div to be 240px wide with a nice bit of padding to keep the text away from the edges" -- the box wouldn't be 240px wide in both IE and Firefox, because they disagree on whether to add the padding to the width of the box.

SO... people use tables. They're more predictable, but they clutter up your code a bit. Plus there's a bit of snobbery about "nested tables"... which are tables inside tables inside tables.

The same goes for DIVs though. Divs inside divs inside divs are just as frowned upon. That's the only instance I can think of where you might say having too many divs is a bad thing. In general you should try to keep things simple, purely because it makes things easier to change later, but there's really no "you must not exceed this number" rule.

A simple layout of a webpage might have one div acting as a frame for the content, then one div floated to the left which contains your navigation, then another div floated on the right which contains your article. Inside the article div you might have another div of highlighted text, another div containing an image with a caption, etc.

Absolute positioning simply says "This is where this element is going to be on the page, regardless of what resolution my viewer is using". You plug in your absolute position like co-ordinates: X many pixels from the top, X many pixels from the left. (Or bottom, or right).

The Z-index is sort of like the layer that the div is on. If you've got one div (or other type of element... like an image) with a Z-index of 1, then it's going to sit underneath an element with a Z-index of 2. When you use Z-indexes and absolute positioning together, it lets you plonk things wherever you like on your webpage without having to be worried about the logical order or natural position of things.

The bad thing is that it's very inflexible, and can break in different browsers. Unless you're wanting to be very arty and minimalist with your site, I wouldn't recommend using these CSS tricks.

And as for frames... they're a nightmare as far as SEO goes. Everything that's good about them can be achieved through much easier and more search engine friendly methods.

That's a really long answer, but I hope that clears things up,
Mark


P.S. Which program are you using to build your site?
  • 0
Limited time special - Pathway to Passive for $37: https://www.affilorama.com/pathwaytopassive
 
PremiumMember
sean06
Posts: 1004
Joined: 16 Jun 06
Trust:
I didn't know you were such a geek Mark :P
  • 0
www.SixDayWeekend.com
Free Training Videos reveal how I make 6 figures while travelling the world
 
PremiumMember
chatyak86
Posts: 1085
Joined: 17 Jun 06
Trust:
sean06 wrote:I didn't know you were such a geek Mark :P


Yea Mark can do a lot of things.... I'm not convinced though until I see him do a backflip on a snowboard. :lol:
  • 0