SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    Forensic SEO Consultant Webnauts's Avatar
    Join Date
    Jun 2003
    Location
    European Union
    Posts
    1,488
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Do "div" tags need attributes?

    I use on my web site "div" tags which some of them have no attributes.
    Aren't attributes normally used with "div" tags intending to provide fuctionality?

    And if attributes are missing, isn't that semantically erroreous?

  2. #2
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,355
    Mentioned
    179 Post(s)
    Tagged
    6 Thread(s)
    What attributes do divs have ?

    You can add title tags to aid readability etc but I think thats going over the top a bit if you add it to every div (but I may be wrong).

    A div is just a generic container for content and where possible a structural html should be used instead.

    e.g. A lot of people do this:
    <div id="header"><h1>Header</h1></div>
    instead of just <h1>Header</h1>.

    Otherwise I'm not really sure what attributes you were talking about

    Paul

  3. #3
    SitePoint Wizard rbutler's Avatar
    Join Date
    Jul 2003
    Location
    Springfield, MO
    Posts
    1,867
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    By attributes do you mean this:
    Code:
      <div width="300">
      some text
      </div>
    Where I would consider width to be an attribute. I don't know why leaving off the width attribute would be erroreous? If you had twenty of these within an HTML file, then if you wanted to change the width of all of them, you would have to change it in every single page, whereas if you used the width attribute in an external style sheet, change it in the style sheet and you're done.

    I personally think putting width in the div tag is not providing very efficient code. Maybe I don't quite follow you on this. Or maybe I followed you completely?

    /*that makes the second time today someone had beat me, not fair!*/
    Ryan Butler

    Midwest Web Design

  4. #4
    Forensic SEO Consultant Webnauts's Avatar
    Join Date
    Jun 2003
    Location
    European Union
    Posts
    1,488
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You got it Bryan. That is what I met! So are you sure that it is not sematically erroreous?

  5. #5
    SitePoint Wizard rbutler's Avatar
    Join Date
    Jul 2003
    Location
    Springfield, MO
    Posts
    1,867
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's toward the end of the work day in my region, so I might be tired, so forgive me, but define sematically erroreous from your view point. If you're meaning if its bad to the language, I'm no CSS guru (intermediate), but it's not necessarily bad to include width in the div (I have done it before), just not efficient, and if Paul sees this, he'll kill me :-), he was the one that set me straight along with PVII.

    Basically when you put width in the div (along with other attributes), you're creating an inline style, which is absolutely worthless in this day in age, except in odd circumstances. Using width in the external style as I mentioned before and then just saying <div id="something">text</div>, would be much better to avoid the CSS guru's chewing your code apart.

    As far as what the CSS "gods" think, that is beyond me, this is just my rule of thumb.

    /*sorry, if you read this three times I had to edit what I said to get it correct from my viewpoint, lol*/
    Ryan Butler

    Midwest Web Design

  6. #6
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,355
    Mentioned
    179 Post(s)
    Tagged
    6 Thread(s)
    Hi,

    So are you sure that it is not sematically erroreous?
    Code:
    <div width="300">
      some text
      </div>
    Not only is it semantically erroneous its also not valid xhtml and will not validate

    There is no attribute "width" for the div element in xhtml.

    Paul

  7. #7
    SitePoint Wizard rbutler's Avatar
    Join Date
    Jul 2003
    Location
    Springfield, MO
    Posts
    1,867
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Straight from the source, told ya! Plus I haven't ventured into xhtml yet.
    Ryan Butler

    Midwest Web Design

  8. #8
    Forensic SEO Consultant Webnauts's Avatar
    Join Date
    Jun 2003
    Location
    European Union
    Posts
    1,488
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Excellent post Paul! How could I be so stupid???
    Sorry everybody for the mess and thanks a lot!


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
  •