Take this ul
for example:
<ul>
<li>HI THERE</li>
<br>
<li>
<p>ME</p>
</li>
</ul>
When the innerHtml of an li
tag is blank, the li
wraps itself right up to the text.
It doesn't happen for the p
tag. I'm assuming this is because p
is for paragraphs which usually have white space breaks before and after.
Is there any way to remove this?
Setting padding to 0px of the parent paragraph tag will remove the space between parent and child paragraphs if one is inside of another. For Example: P{
Approach 1: We can remove space between any two tags by simply using margin-bottom property. The margin-bottom property sets the bottom margin of an element. We will assign a negative value to the margin-bottom of a particular tag to eliminate the extra space between the tags as shown.
How do I reduce the gap between two sections in HTML? Using inline styling, you can identify the paragraphs you wish to remove space from and write in the following: style=”padding: 0px; margin: 0px;”If you want to center all paragraphs, add it to your CSS in the style tag: <style>
<p>
elements generally have margins and / or padding. You can set those to zero in a stylesheet.
li p {
margin: 0;
padding: 0;
}
Semantically speaking, however, it is fairly unusual to have a list of paragraphs.
Look here: http://www.w3schools.com/tags/tag_p.asp
The p element automatically creates some space before and after itself. The space is automatically applied by the browser, or you can specify it in a style sheet.
you could remove the extra space by using css
p {
margin: 0px;
padding: 0px;
}
or use the element <span>
which has no default margins and is an inline element.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With