Lukasz Formela
Lukasz Formela

Reputation: 447

Remove whitespace around text in div

Is it possible to remove white space at the end of text with CSS (or optionally with JS)? I've tried all kinds of display property, but none of them seem to work. I would need to dynamically insert a blink-div at the end of multi line sentence. Currently it's is being added outside of phrase-div that contains sample text (which, as a div, is rectangular with white space I don't need). HTML structure looks like this:

<div id="writr-div">
    <div id="phrase-div"></div>
    <div id="blink-div"></div>
</div>

Please check out the both images:

Original:

enter image description here

Desired effect (border and background are for preview purpose):

enter image description here

EDIT: Okay, I may haven't made myself clear enough. This is what I want (that's not an absolute position, I need it to be at the end of the sentce, no matter how long it is):

enter image description here

Thanks, Luca

Upvotes: 1

Views: 1358

Answers (1)

Temani Afif
Temani Afif

Reputation: 272817

Simply use span:

#writr-div {
  width:140px;
  border:1px solid;
}
#blink-div {
  border:1px solid red;
} 
<div id="writr-div">
    <span id="phrase-div">Some text here and there</span>
    <span id="blink-div"> another text</span>
</div>

Upvotes: 2

Related Questions