It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming HTML Forum

HTML Grammar question

HTML Grammar question

Postby GilDawson on Mon Nov 29, 2010 6:51 pm

Hi--

I have a little html code that produces two similar paragraphs. The only structural difference in the two paragraphs is

a line-end appears in the second paragraph between the two /font tags.

I expected the line-end to be treated as white space and ignored. It is ignored in Safari Version 5.0.2 (6533.18.5), but it is not ignored in Firefox (Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12).

When rendered in Firefox, the second line in the second paragraph appears just a little bit lower below its first line than in the first paragraph.

Can you help me understand why this difference?

Here's the code:

<html>
<head>
</head>
<body>
<p<font face="Arial">This is the 1st line in the 1st paragraph.<br />
<font size="2">This line is just below it.</font></font></p>
<p><font face="Arial">This is the 1st line in the 2nd paragraph.<br />
<font size="2">This line renders lower in Firefox.</font>
</font></p>
</body>
</html>

--Gil
GilDawson
 
Posts: 4
Joined: Mon Nov 29, 2010 5:21 pm

Re: HTML Grammar question

Postby EMaks on Mon Nov 29, 2010 8:01 pm

Check line 8 and 9. Both of them should be on the same line. But, it's better to use css for layout, font tags aren't good. And in line 5 you didn't put close bracket on p tag.
EMaks
 
Posts: 14
Joined: Wed Nov 24, 2010 10:32 am

Re: HTML Grammar question

Postby GilDawson on Mon Nov 29, 2010 8:55 pm

EMaks wrote:Check line 8 and 9. Both of them should be on the same line.


Well, yes, that would make them display the same in both Firefox and Safari. My question is, Why does Firefox care? Line-ends are generally ignored, are they not?

EMaks wrote:better to use css


In many cases, yes. However, I've inherited this code and wish to understand it.

EMaks wrote:didn't put close bracket on p tag


Yes, thanks. However, fixing that does not change the rendering.

Thanks for the reply.

--Gil
GilDawson
 
Posts: 4
Joined: Mon Nov 29, 2010 5:21 pm

Re: HTML Grammar question

Postby EMaks on Mon Nov 29, 2010 9:28 pm

Line-ends are generally ignored, are they not?

No, they aren't. I just can't remember another example, but sometimes there is a difference, whether there is a line-break or even space (which is the same) in html between tags or not. So you should pay attention to it!
EMaks
 
Posts: 14
Joined: Wed Nov 24, 2010 10:32 am

Re: HTML Grammar question

Postby pep1439 on Fri Dec 03, 2010 10:52 am

Browsers have their own styles and settings to display elements results different experiences.
pep1439
 
Posts: 7
Joined: Wed Dec 01, 2010 2:11 pm


Who is online

Users browsing this forum: No registered users and 5 guests