SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    Technically, a bit dim macdan's Avatar
    Join Date
    Feb 2001
    Location
    London
    Posts
    344
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    correct use of <div>?

    Hi

    I have a client who is questioning my use of the div tag to apply classes to small areas of text such as : <div class="mystyle">text</div>

    It works fine but they are implying that it's a bit of a hack - what is the correct usage of this tag? - can anyone tell me what the the div tag stands for and is it compliant/good practice to use it to apply text formatting to a single line of text?

    Thanks for any comments.
    gorillaweb is a small London based digital design agency.

  2. #2
    SitePoint Guru sowen's Avatar
    Join Date
    Feb 2001
    Location
    Stockport, UK
    Posts
    729
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <div> is a block level attribute like <p> for small inline class changes you should use <span>.

  3. #3
    Technically, a bit dim macdan's Avatar
    Join Date
    Feb 2001
    Location
    London
    Posts
    344
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cheers sowen that would explain why you get an automatic line break after using div. I'll use span from now on which presumably doesn't give the line break.
    gorillaweb is a small London based digital design agency.

  4. #4
    blonde.... Sarah's Avatar
    Join Date
    Jul 2001
    Location
    Berkshire, UK
    Posts
    7,442
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    you can also use class which becomes part of <P> also i.e. <P class=style>

  5. #5
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can apply a class to ANY HTML tag. As mentioned earlier, DIV is a block level element and as such implies a carriage return after the closing tag.

    SPAN is the best tag to use to apply formatting to a single word or sentence.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes


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
  •