Forum Moderators: open

Message Too Old, No Replies

Netscape 6+ handles <br clear="left" /> wrongly?

Line break with clear causes large gap of white space

         

StepOne

9:51 pm on Jul 23, 2004 (gmt 0)

10+ Year Member



Dear All,

I have been writing a XHTML 1.0 Transitional page which has an image on the left and some text to the
right of the image. The text does not come down to the bottom edge of the image. I've used
<br clear="left" /> so that the new heading below both the image and the text, would be in clear space
and at the left margin.

ie.

<img src="images/****.jpg" width="347" height="117" alt="****" align="left" hspace="12" vspace="8" />
<p>text,text,text,text,text,text,text,text,text,etc</p>

<br clear=left" />

<p>New heading here</p>

With Internet Explorer 5+ and even Netscape 4.x this works just fine, but with Netscape 6.x or 7.x or
Firefox the new heading is moved down the page by at least 6 lines leaving a large gap of white space.

The way I get around this is to use a number, maybe 5 or 6 simple line breaks ie. <br />,
then all is well. I could continue to do this but would love to know a better way. I've tried <br clear="all" /> which has the same problem.

Why does Netscape 6+ handle line breaks differently to other browsers and is there a neat way around this
other than what I'm already doing?

Many thanks.

tedster

10:40 pm on Jul 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There's a very good chance you are seeing the difference between true standards mode rendering and quirks mode rendering. In other words, it's the display of the img tag, and not the<br /> tag that, is different.

See: [webmasterworld.com...]

Does that give you any help?

BlobFisk

8:54 pm on Jul 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's also worth mentioning that the W3C has deprecated the clear attribute in favour of a CSS solution...

[w3.org...]

StepOne

9:28 pm on Jul 24, 2004 (gmt 0)

10+ Year Member



Hi tedster,

Firstly, many thanks for taking the time to reply but no, unfortunately it doesn’t seem to be the difference between quirks and true standards mode.

I have been using:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

but if I remove this and have no DTD at all, it makes no difference to the problem I’m experiencing.

It’s very odd, is there anything else you can think of?

tedster

10:04 pm on Jul 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I doubt that it's the <br /> tag - something like that would have been noticed and fixed
ages ago. In addition, I cannot recreate the problem, based on the snippet in yor first post at least.

Before you go any further, I assume you ran your page through the W3C Validator, but if not do that first and deal with any errors.

After you've done that, then let's look at a few things...

1) Is it just a copy/paste error, or are you really missing a quote mark around clear=left"?

2) I suggest you get rid of the hspace and vspace attributes (they're deprecated) and use css padding or margins instead.

3) Similarly, instead of using the align attribute in the image tag, use css and a float="left" rule for the image.

StepOne

12:15 am on Jul 26, 2004 (gmt 0)

10+ Year Member



“I doubt that it's the <br /> tag - something like that would have been noticed and fixed”

Yes, I’m sure it’s something that I am doing that’s at fault.

“Before you go any further, I assume you ran your page through the W3C Validator”

Yep, I use Tidy routinely and it also passes the W3C Validator test.
BTW the missing quote mark was just an example of my rotten typing.
I would love to get rid of the hspace and vspace tags and use CSS but when I do so the page goes pear shaped when viewed with Netscape 4.x and I’ve never been able to find away around this.

Try viewing the following HTML, the laptop I’m using has Netscape 7.1 and IE 5.5 and these two browsers illustrate what I’m seeing very clearly. Removing the table cures the problem, but its needed to hold the page together.

<html>
<head>
<title></title>
</head>
<body>
<table width="750" cellspacing="0" cellpadding="0" summary="The table contains...">
<tr>
<td>
<p>Heading</p>

<img src="***.jpg" width="347" height="117" alt="***" align="left" hspace="12" vspace="3" border="1">
<p>Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text</p>

<br clear="left">
<br>

<p>New heading here</p>
</td>
</tr>
</table>
</body>
</html>

tedster

4:29 am on Jul 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think we're seeing a difference in margin collapsing rules.

How about dropping all the <br> approach -- which is semantically questionable anyway. Give the <p> tag a style:

<p style="clear:left;">New heading here</p>

StepOne

10:30 am on Jul 26, 2004 (gmt 0)

10+ Year Member



"How about dropping all the <br> approach -- which is semantically questionable anyway. Give the <p> tag a style:"

Thanks tedster, that was useful. In future I will use the <p style="clear:left;"> method.