SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Feb 2003
    Location
    eez
    Posts
    331
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    When should I use <p and when should I use <div?

    Hi!

    When should I use <p and when should I use <div?

    Some only use <p strictly for paragraphs, others for almost everything. What do you think?

    Thanks

  2. #2
    Pedantic Semantic blain's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    528
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <p> should be used when you want to specify a paragraph, <div> should be used to divide your html.
    Technology is dominated by two types of people:
    those who understand what they do not manage,
    and those who manage what they do not understand.

  3. #3
    SitePoint Addict
    Join Date
    Feb 2003
    Location
    eez
    Posts
    331
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well I know that... could you give me some precise examples?

  4. #4
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use <p> just for tekst (paragraph).

    Use <div> if you want to create some kind of box with content for example image with caption or news containing: header <hx />, paragraph <p>, image <img />, date <p>...

    Div is usefull when you want to create collection of tags, if you want to group them all and then position on the webpage as a one element.

  5. #5
    Pedantic Semantic blain's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    528
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HTML Code:
    <div>
    <h1>Lorem Ipsum</h1>
    <p>Lorem ipsum dolor sit amet, consectetuer adipiscing 
    elit. Nulla hendrerit ante eu augue. Proin pretium magna 
    quis pede. Suspendisse potenti. Duis vitae ante nec 
    risus dapibusimperdiet. Aenean a urna. In auctor metus 
    id lectus bibendum mollis. Aliquam tincidunt pharetra 
    lectus. Integer ultrices nonummy mi. Sed egestas massa 
    vel diam.</p>
    
    <p>Phasellus rhoncus, arcu sit amet ullamcorper 
    venenatis, justo massa lacinia dolor, id porta ante libero 
    id ligula. Nullam pretium quam quis orci.Curabitur vitae 
    urna. Suspendisse urna elit, porttitor non, tincidunt 
    vitae, hendrerit ac, ligula. Aliquam elementum 
    accumsan velit.</p>
    </div>
    Technology is dominated by two types of people:
    those who understand what they do not manage,
    and those who manage what they do not understand.

  6. #6
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A paragraph is one or more sentences that deal with a single, specific thought. This paragraph, for instance, contains two sentences.

    When you move on to talk about another thought, you'll start a new paragraph, like this one.

    On web pages, paragraphs are usually separated by whitespace corresponding to a blank line. In printed matter, paragraphs are often run together, using some indention of the first line to indicate the start of each new paragraph.

    DIVs are generic block-level containers, which you use when there is no semantically correct element type available. It can be used for grouping a number of elements that belong together, so that you can address the group as a whole (e.g., for styling purposes).
    Birnam wood is come to Dunsinane


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
  •