Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Cross-Browser Compatible CSS Snippet

Posted on 2009-03-30
6
Medium Priority
?
402 Views
Last Modified: 2013-11-19
The following XHTML and the attached CSS works fine in most browsers; however, in some browsers such as IE 6 it gets all out of whack. Is there anyway I can optimize this code to work in IE 6 and beyond. A working example of this code can be found here: http://www.emarketbuilders.com/portfolio/

<div class="holder" style="margin-bottom:10px ">
  <div class="pcontainer">
    <div class="pphoto"></div>
    <div class="ptext">
      <div class="arrowlink" style="float:right ">
      </div>
    </div>
  </div>
</div>
.holder{overflow:auto}
div#pcontatiner{float: left; width: 501px; margin: 10px 0px 0px 0px}
div.pphoto{float: left; width: 150px; margin:10px 5px 10px 10px}
div.ptext{float: left; width: 331px; margin: 10px 0px 10px 0px}

Open in new window

0
Comment
Question by:EMB01
  • 3
  • 3
6 Comments
 
LVL 3

Expert Comment

by:blatantwaste
ID: 24022988
remove the float for ie6
<!--[if lte IE 6]>
<style type="text/css">
.holder{overflow:auto}
div#pcontatiner{width: 501px; margin: 10px 0px 0px 0px}
div.pphoto{width: 150px; margin:10px 5px 10px 10px}
div.ptext{width: 331px; margin: 10px 0px 10px 0px}
</style>
<![endif]-->

Open in new window

0
 
LVL 14

Author Comment

by:EMB01
ID: 24023012
Do I stick that right in the CSS so the end result would be as attached?
.holder{overflow:auto}
div#pcontatiner{float: left; width: 501px; margin: 10px 0px 0px 0px}
div.pphoto{float: left; width: 150px; margin:10px 5px 10px 10px}
div.ptext{float: left; width: 331px; margin: 10px 0px 10px 0px}
<!--[if lte IE 6]>
<style type="text/css">
.holder{overflow:auto}
div#pcontatiner{width: 501px; margin: 10px 0px 0px 0px}
div.pphoto{width: 150px; margin:10px 5px 10px 10px}
div.ptext{width: 331px; margin: 10px 0px 10px 0px}
</style>
<![endif]-->

Open in new window

0
 
LVL 3

Accepted Solution

by:
blatantwaste earned 2000 total points
ID: 24023379
No, that would go in the head of your page between the <head> and </head> tags... so it would look like:
<html>
<head>
<title>Blah</title>
<style type="text/css">
These are your normal styles here...
</style>
 
<!--[if lte IE 6]>
<style type="text/css">
.holder{overflow:auto}
div#pcontatiner{width: 501px; margin: 10px 0px 0px 0px}
div.pphoto{width: 150px; margin:10px 5px 10px 10px}
div.ptext{width: 331px; margin: 10px 0px 10px 0px}
</style>
<![endif]-->
</head>
<body>
body stuff...
</body>
</html>

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 14

Author Comment

by:EMB01
ID: 24023417
That means the browser knows to render that CSS if it's IE6 instead of the CSS that exists further down the page? Where can I read more about that type of stuff (<!--[if lte IE 6]>)?
0
 
LVL 3

Expert Comment

by:blatantwaste
ID: 24023807
that basically says if the browser is Less Than or Equal to Internet Explorer 6, then apply whatever is contained within the "if" statement...

You can read more about it here: http://msdn.microsoft.com/en-us/library/ms537512.aspx
0
 
LVL 14

Author Closing Comment

by:EMB01
ID: 31564483
Thanks for your help!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question