SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Caveat surfer Buddy Bradley's Avatar
    Join Date
    May 2003
    Location
    Cambridge, UK
    Posts
    2,366
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Which tags do you use when applying CSS?

    I've read and heard conflicting ideas on which HTML tags should be used to apply CSS styles to text.

    My book says to use <div> and <span> for block-level and inline style application, but I've also been told to use <p> and header (e.g. <h1>) for the same thing.

    What do you use, and is there any benefit to using one tag over another?

    PS: can someone tell me why the SitePoint forums need a horizontal scrollbar in 1024x768?

  2. #2
    gingham dress, army boots... silver trophy redux's Avatar
    Join Date
    Apr 2002
    Location
    Salford / Manchester / UK
    Posts
    4,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    using <p> and heading makes sense from a semantic/structural point of view. if something is a heading, it should be marked up using a heading...
    <div> and <span> are catch-all containers, they don't have any structural meaning beyond that.
    search engine bots (e.g. googlebot) give more importance to keywords found within headings. screenreaders (e.g. JAWS) can extract a document's structure by presenting a user with just the headings themselves.

    hope that made some kind of sense. in short, use the appropriate tag whenever it makes sense.
    re·dux (adj.): brought back; returned. used postpositively
    [latin : re-, re- + dux, leader; see duke.]
    WaSP Accessibility Task Force Member
    splintered.co.uk | photographia.co.uk | redux.deviantart.com

  3. #3
    SitePoint Evangelist azizur_rahman's Avatar
    Join Date
    Nov 2001
    Location
    London, UK
    Posts
    502
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you are writting say an Article you should use the <hx> and <p> tags as you want it to flow naturelly when reading. W3C recommends you use <hx> and <p> tags for (x)HTML. you could easily combine any CSS to these HTML tag so there shouldn't be any problem which ever you use.

    You could also use the DIV tag to highlight the Headings and so on, but what if your style sheet is being turned of by user browser, then the reader does not know where a new paragraph starts or under which heading they are reading what.

    I'd only user <div> and <span> highlight key points say a quote in the article or something short text I want to get reader attetion to.
    Azizur Rahman
    Web Application Developer

  4. #4
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    I use <div>s to "section off" my documents. For example, I'll have a header, a menu, main content, and a footer, all marked up in <div>s. Within those blocks I'll use tags as I need 'em. For example, my content <div> is usually marked up in headings and paragraphs on a text-heavy page, and my menu <div> is usually marked up as an unordered list (a list of links).


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
  •