Connecting Tech Pros Worldwide Help | Site Map

Line Break Difference in IE and FireFox

Newbie
 
Join Date: May 2009
Posts: 4
#1: May 9 '09
Expand|Select|Wrap|Line Numbers
  1. <style>
  2. a.valuetype2 {
  3.   width:200px;
  4.   height:200px;
  5.   border: 1px solid #666666;
  6.   display:inline;
  7. }
  8. </style>
  9.  
  10. <a href=.. class=valuetype2> <img src=picture.gif> <p> Some Text </a>
  11. <a href=.. class=valuetype2> <img src=picture2.gif> <p> Some Text 2 </a>
With the display:inline css line in Internet Explorer the two links are side by side with no line break. In Firefox the links are on top of each other. I want the links to be side by side, the display inline works in IE but not in Firefox. Why is this and how can I make Firefox work?
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#2: May 9 '09

re: Line Break Difference in IE and FireFox


If I remember correctly, anchors are naturally inline. But looking at your code, I would guess it's the block level P tags that are causing the line break.
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,561
#3: May 9 '09

re: Line Break Difference in IE and FireFox


You can use CSS to say an element is to be displayed inline but that doesn't make the html valid. Paragraphs cannot be enclosed in an anchor element because the DOM tree will still be wrong.
Newbie
 
Join Date: May 2009
Posts: 4
#4: May 9 '09

re: Line Break Difference in IE and FireFox


It is a layout issue. I want a rectangle and inside the rectangle I want an image and then some text underneath it. Then I want another rectangle just like it to the right of it and so on. IE and Firefox will put the rectangles side by side, but if I do a <br> or <p> tag (the text below the picture) within the rectangle Firefox puts the whole rectangle underneath each other instead of side by side like IE. I don't understand why you can't have boxes with elements inside them and put them side by side in firefox.
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,561
#5: May 9 '09

re: Line Break Difference in IE and FireFox


You can but you have to use the language properly. What you have may have worked in IE but that was by accident rather than design.

I'll try and look at this better in a bit.
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,561
#6: May 9 '09

re: Line Break Difference in IE and FireFox


<p>
<a><img src="">Text here</a><a href=""><img src="">Text here</a>
</p>
Newbie
 
Join Date: May 2009
Posts: 4
#7: May 9 '09

re: Line Break Difference in IE and FireFox




I do a bad job describing the problem so I added a pic. The code displays side by side in Internet Explore, but the same code displays in FirexFox in example 2. How do I code the html and css so than is displays in Firefox like example 1.
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,561
#8: May 10 '09

re: Line Break Difference in IE and FireFox


This is one way to do it.
Expand|Select|Wrap|Line Numbers
  1. <style type="text/css">
  2. a{display:block;float:left}
  3. span{float:left}
  4. </style>
  5. <body>
  6. <p>
  7. <a href=""><img src="1.gif"><span>text</span></a><a href=""><img src="1.gif"><span>text</span></a>
  8. </p>
  9. </body>
  10.  
Newbie
 
Join Date: May 2009
Posts: 4
#9: May 10 '09

re: Line Break Difference in IE and FireFox


Thanks, I inserted float:left into the css sytle and it works now.

Thanks again
Reply

Tags
display:inline, firefox