Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IE7 inline elements 2

Status
Not open for further replies.

ca8msm

Programmer
Joined
May 9, 2002
Messages
11,327
Location
GB
Why doesn't IE7 wrap the inline elements down to the next line, and what would be a suggested workaround (maybe floating instead)?
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
  #container {width:300px;}
  h2 {display:inline;padding:5px;}
</style>
<title>Title</title>
</head>

<body>

<div id="container">
	<h2>Test</h2>
	<h2>Test</h2>
	<h2>Test</h2>
	<h2>Test</h2>
	<h2>Test</h2>
	<h2>Test</h2>
	<h2>Test</h2>
	<h2>Test</h2>
	<h2>Test</h2>
	<h2>Test</h2>
	<h2>Test</h2>
	<h2>Test</h2>
	<h2>Test</h2>
	<h2>Test</h2>
	<h2>Test</h2>
	<h2>Test</h2>
	<h2>Test</h2>
	<h2>Test</h2>
	<h2>Test</h2>
	<h2>Test</h2>
	<h2>Test</h2>
	<h2>Test</h2>
	<h2>Test</h2>
	<h2>Test</h2>
	<h2>Test</h2>
</div>

</body>
</html>


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
...(maybe floating instead)?

Maybe add float (rather than instead).
Code:
...
  h2 {display: inline; padding:5px; float:left;}
...

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Yes, I could add a float, I was just curious as to why it happened (is Firefox correct in it's assumption that they should wrap?) and what you all thought was the best workaround?


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
AFAIK, they do not wrap because of the padding. IE believes that by adding padding the elements should no longer wrap. I have no idea why that is. On the other hand, you have a lot of white-space between the tags, so I would expect them to wrap. Have you tried it with a native inline element as well, such as span, strong or similar?

___________________________________________________________
[small]Do something about world cancer today: PACT[/small]
 
Hmmm, even if I remove the padding, IE7 doesn't wrap them? Using a native inline element does produce the correct layout I wanted and in my specific case, a span tag should be just as relevant, so I may go with that approach or the float method suggested earlier.

Thanks for the responses.


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top