Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Mar 2011
    Posts
    164
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Are too many closing </divs> bad?

    Hi just curious is it is bad to have an extra closing </div> in your code?

    I have a page that has many divs and it is such a headache trying to work out which one relates to which tag...

    So I mean

    <div>html code</div>

    and then a lurking </div> - is this bad to have lurking there or will all browsers ignore an orphoned div tag?

    Thanks

  • #2
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    Having mismatched tags may or may not affect browsers atm but the code is invalid according to the w3c validator. Mismatched tags might cause web pages to break in future browser releases though.

    If you use a reputable IDE like Netbeans or something similar, it indents all your code for you which makes it much easier to spot mismatched tags. Also if you click on a tag, it will highlight its matching tag if it exists.

  • #3
    New Coder
    Join Date
    Apr 2011
    Posts
    15
    Thanks
    0
    Thanked 1 Time in 1 Post
    If you use too many hidden <div> and <span> its really bad and affects in SEO. Other than that..I don't think its a wrong use.

  • #4
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,630
    Thanks
    6
    Thanked 1,002 Times in 975 Posts
    You can’t expect cross browser consistent results with erroneous code – that that’s what redundant closing tags is. You should always format your code properly when writing it (i. e. indent and maybe comment it to remember what is where).


  •  

    Posting Permissions

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