Div coding assistance

Discussion in 'HTML & Website Design' started by hchuk, Nov 18, 2010.

  1. #1
    I am trying to get my head around DIV code tags and want to ask a simple ish question.

    If I open a div statement and then open another div statement, how does the page know which closing tag is for which statement, or does it not matter?
     
    hchuk, Nov 18, 2010 IP
  2. radiant_luv

    radiant_luv Peon

    Messages:
    1,327
    Likes Received:
    34
    Best Answers:
    1
    Trophy Points:
    0
    #2
    "div" is not a statement (if you referring a programing term), it's an element/ tag.
    Every html tag which is opened needs to have a closing tag as well.

    for example:
    
    
        <div>your content</div>
    
    
    Code (markup):
     
    radiant_luv, Nov 18, 2010 IP
  3. Network Interaction

    Network Interaction Peon

    Messages:
    47
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    just a sample

    <div id="header"><!--this for open header-->
    
    some statements here
    
    <div id="menu"><!--this for open menu-->
    
    some statements here
    
    </div><!--this for close menu-->
    </div><!--this for close header-->
    
    
    PHP:
     
    Network Interaction, Nov 18, 2010 IP
  4. radiant_luv

    radiant_luv Peon

    Messages:
    1,327
    Likes Received:
    34
    Best Answers:
    1
    Trophy Points:
    0
    #4
    ==^ above is not PHP code
     
    radiant_luv, Nov 18, 2010 IP
  5. chatman2222

    chatman2222 Peon

    Messages:
    20
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    No one said anything about PHP...

    @OP in html when you close a tag is closes the most recently opened one. Simples.
     
    chatman2222, Nov 18, 2010 IP
  6. ronc0011

    ronc0011 Peon

    Messages:
    85
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    All tags have an opening and closing tag i.e.

    Open div tag <div>

    closing div tag </div>

    open paragraph tag <p>

    closing paragraph tag </P>

    Closing tag always has the "/" at the beginning. The "/" means it's the closing tag.

    A div tag is a container. Something you can put other stuff in like paragraphs or images or even other div tags etc.

    div tags can be nested i.e. you can put div tags inside other div tags.
    When you nest tags they are ordered from the middle out or if you prefer visa versa. i.e.

    
    <div>      /*Opening parent tag */
    
       <div>     /* Opening child tag */
      
       </div>    /* Closing child tag */
    
    </div>    /* Closing parent tag */
    
    
    Code (markup):
    Some tags like image tags "img" are self closing i.e.

    <img src="myImage.jpg" />

    The closing "/" is included at the end of the tag. the break tag is another such tag;


    <br />
     
    ronc0011, Nov 18, 2010 IP
  7. littlewing1977

    littlewing1977 Greenhorn

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #7
    Make sure you use proper nesting. ronc0011 has a good example. Picture your div like a box. Your second box has to be completely inside the first. This is the same with any HTML tag.
     
    littlewing1977, Nov 19, 2010 IP