If the HTML document contains line break in element content, as in
<div>
ya
hoo.com
</div>
as you seem to be saying, then you cannot prevent the line break as being taken as whitespace, in HTML or CSS. You can affect (in CSS) the way whitespace is handled (e.g., whether line breaks cause line breaks in rendering or just inter-word space), but this does not include the “ignore it” option.
Well, there is a tricky and risky way of setting word-spacing
to some negative value that is expected to cancel the effect of spaces.
<div style="word-spacing: -0.25em">
ya
hoo.com
</div>
The typical width of a space is about 0.25em, but it varies by font. And this would affect (“neutralize”) all whitespace in the element.
It is easy to remove line breaks with JavaScript, once you have specified which line breaks are to be removed from where. But it is better to modify the process that generates the HTML document in the first place.