zxed
zxed

Reputation: 11

Browser treats newline as newline and not space

I was asked "How come in newer browsers, newlines are treated as newlines"... a very odd question as I would expect, based on the question, that the seen behavior was expected.

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<html>
<head>

<title>
</title>
</head>
<body>
<p title="test 
test 
test">test a b c</p>
</body>
</html>

However, if you look into the past examples., newlines were treated as spaces., and not newlines., Why does the browser renders a newline as space?

so; using CSS, how do you get the newer browsers to treat the new lines as spaces?

If you were to create the above in notepad and save it as html., the tooltip would show as

test
test
test

and not the expected

test test test

Upvotes: 1

Views: 583

Answers (1)

Alain Pannetier
Alain Pannetier

Reputation: 9514

This applies only to tooltips.

Webkit browsers (Chrome, Safari) do it.
Gecko browsers (FF, Flock...) don't.
IE 7+ does (don't know before).

It gives the author the possibility to format a little bit long tooltips so that they don't span across the whole width of the page. Please note that most browsers (including Gecko based browsers) nevertheless also feature automatic boxing algorithms to keep the tooltips readable. It's just that the ones supporting this feature also give more controls to the author).

Since it applies only to tooltips, no CSS attribute can affect this behaviour.

Upvotes: 3

Related Questions