SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru
    Join Date
    Nov 2008
    Posts
    625
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    display content acording to browser

    hi

    i know we can write conditional statements in <head></head> to write browser specific css stylesheet.

    But if i want to display content inside the <body></body> then what do i have to do ?

    My below code show both lines in IE7.

    i want to show only IE7 Specific content in IE7

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    <p>here comes content for mozilla firefox</p>
    <!--[if IE]>
    <p>here comes content for internet explorer</p>
    <![endif]-->
    </body>
    </html>
    vineet

  2. #2
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,118
    Mentioned
    28 Post(s)
    Tagged
    2 Thread(s)
    Conditional comments work anywhere in the document so that should work fine.

    You can target IE7 specifically with <!--[if IE 7]>

    You can also use this form for targeting non-ie browsers.
    <!--[if !IE]> -->
    FF, Chrome, Safari, Opera..
    <!-- <![endif]-->

  3. #3
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,329
    Mentioned
    463 Post(s)
    Tagged
    8 Thread(s)
    Another option would be to give each paragraph a special class, and hide one paragraph from all browsers except IE7 with display: none and show one paragraph to all browsers but IE7. You could do this via conditionals styles or via a hack that only IE7 recognizes. E.g.

    Code:
    .all {display: block;}
    .ie {display: none;}
    
    * + html .all {display: none;}
    * + html .ie {display: block;}

  4. #4
    SitePoint Guru
    Join Date
    Nov 2008
    Posts
    625
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks Mark and Ralph

    Both of your solutions will do my task

    vineet


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
  •