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

I want

Please advise and read my simple attached php html code

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

Open in new window

LVL 13
Who is Participating?
Chris StanyonConnect With a Mentor Commented:
Try white-space:

<p style="white-space: nowrap;">aaaaaaa-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</p>

Open in new window

Dave BaldwinFixer of ProblemsCommented:
Chris is right.  '-' is one of the few characters that will allow text wrapping because that is the way it has traditionally been used.
duncanb7Author Commented:
why &#45 is not working ?
I replaced space with &nbsp; that is working if space is inisde to break the line
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

Chris StanyonCommented:
&#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)
duncanb7Author Commented:
Thanks for all of your reply
duncanb7Author Commented:
Reminder or memo: nbsp mean non-breaking space not just space for html entity
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.