SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: too many divs?

  1. #1
    SitePoint Addict smittenbite's Avatar
    Join Date
    Jul 2005
    Location
    Friendswood
    Posts
    397
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Red face too many divs?

    just wondering but while im doing my site in css, i find that i keep making divs for everything and now theres divs inside divs and more divs all around those two divs!

    i just wanna ask is this normal to have so many divs or am i supposed to be organizing my content some other more effective way?
    nothing.

  2. #2
    Non-Member lostseed's Avatar
    Join Date
    Sep 2005
    Location
    Zurconion Soon!
    Posts
    1,549
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure you havent left an example, too many DIV's aren't good and there is always a way to reduce them. If you use firefox, which I hope you do, I suggest using this extension: http://www.karmatics.com/aardvark/
    After *.xpi is installed Right Click > Start Aardvark

    or try using the FF Web Developer Extention:
    https://addons.mozilla.org/extension...info.php?id=60
    After *.xpi is installed just go through the OUTLINE feature to see how its layed out!

    Then

    Go to a few sites made in CSS possibly look through these sites at:
    http://thesis.veracon.net/index.php

    And see how they do it.
    I just suggest this because its really up to you and what you're comfortable with,
    I usually have about 4 or 5 DIVS for the layouts I make. Maybe 3, not much more. But again its up to you, you just gotta use some shortcuts =]

  3. #3
    SitePoint Wizard drhowarddrfine's Avatar
    Join Date
    Aug 2005
    Posts
    3,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The term is 'divitis'. Some people wrap everything in divs but it's not necessary and only adds confusion. Think of divs as containers to keep related information together. You don't need a div around every img or paragraph. I know of some web pages with no divs at all. So, if you don't know why you are putting a div in then it's probably not needed.

  4. #4
    SitePoint Addict smittenbite's Avatar
    Join Date
    Jul 2005
    Location
    Friendswood
    Posts
    397
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks guys i guess ill try to reduce the amount of divs i have, theyre giving me a headache anyways
    nothing.

  5. #5
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Whenever you need a div, ask yourself whether there already is a more suitable element type in HTML. If you have something like this:
    HTML Code:
    <div class="heading">Foo</div>
    ...then you should change it to:
    HTML Code:
    <h1>Foo</h1>
    If you have this:
    HTML Code:
    <div class="contact-info">...</div>
    ...then what you really want is:
    HTML Code:
    <address>...</address>
    Etc.
    Simon Pieters

  6. #6
    Non-Member lostseed's Avatar
    Join Date
    Sep 2005
    Location
    Zurconion Soon!
    Posts
    1,549
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by drhowarddrfine
    The term is 'divitis'. Some people wrap everything in divs but it's not necessary and only adds confusion. Think of divs as containers to keep related information together. You don't need a div around every img or paragraph. I know of some web pages with no divs at all. So, if you don't know why you are putting a div in then it's probably not needed.
    I thought it ment Divider

  7. #7
    SitePoint Wizard bronze trophy Tyssen's Avatar
    Join Date
    Oct 2005
    Location
    Brisbane, QLD
    Posts
    4,067
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The other thing to watch out for is adding divs because you think they're needed for applying a certain style. For instance, you often see unordered lists inside a div because the div has a border or background colour or maybe position applied to it, when all those styles could just as easily be applied to the <ul> itself.
    And as zcorpan pointed out, there should be very few (if any) cases where a div should just contain text because there are other elements better suited for the job.

  8. #8
    SitePoint Wizard drhowarddrfine's Avatar
    Join Date
    Aug 2005
    Posts
    3,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lostseed
    I thought it ment Divider
    Divitis is the name of the disease with the symptom of using too many divs.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •