Avatar of duncanb7
duncanb7 asked on

minus sign html enitity is not working

Dear Experts,

I want my one-line paragraph can be scrolled when it is overflow in div tag.
But the string in the paragraph has minus sign of "-" that will
break the one  line into two lines. WHy ?

I want it displayed in one line even minus-sign in the string so  I
tried to replace "-" minus sign by &#45 that is html code. But it is not
working, it still breaks it into two lines.

Now it is displayed as follow if "-" is inside
aaaaaaa-
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

I want
aaaaaaa-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

Please advise and read my simple attached php html code
Duncan

<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<head>
</head>
<body>
<?php
echo "<div style='overflow-x:scroll;overflow-y:scroll;background-color:yellow;width:300px;height:300px;font-size:14px'>";
echo<p>aaaaaaa-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n</p>";
echo '</div>';
?>
</body>
</html>

Open in new window

CSSHTMLPHP

Avatar of undefined
Last Comment
duncanb7

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Chris Stanyon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Dave Baldwin

Chris is right.  '-' is one of the few characters that will allow text wrapping because that is the way it has traditionally been used.
ASKER
duncanb7

why &#45 is not working ?
I replaced space with &nbsp; that is working if space is inisde to break the line
Chris Stanyon

&#45; is exactly the same as - so it will have exactly the same behaviour.

The &nbsp; works because that's what it's supposed to do (Non Breaking SPace)
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER
duncanb7

Thanks for all of your reply
ASKER
duncanb7

Reminder or memo: nbsp mean non-breaking space not just space for html entity