Jump to content

How to remove whitespace after/inside <div>?


Recommended Posts

Assume the following code:

<div class="foobar">
"whitespace"
<p>....</p>
</div> 

"whitespace" is not the text but a whitespace as indicated in Firefox WebDeveloper.

How can I get rid of every whitespace inside after a <div class=foobar"> and the first <p> with Javascript?

Link to post
Share on other sites

.foobar, .foobar * {display: inline-block; }

The reason you would be having what you call whitespace is because the div and paragraph are block elements, meaning they will fill the total width available to it, causing it to stack below any content.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...