How to remove extra space under paragraph in HTML/CSS

こ雲淡風輕ζ 提交于 2019-12-08 18:03:35

It's common for browsers to give paragraphs a default margin. So just take it away.

Give the <p> a margin of 0:

.Box p{
    margin: 0;
}

Check it here: http://jsfiddle.net/aG27X/

That's the default padding/margin of p element, try using

.Box p {
   margin: 0;
   padding: 0;
}

You should reset browser defaults before designing any webpage, if you want a quick solution than using

* {
   margin: 0;
   padding: 0;
}

Will suffice your needs, you can also google out for CSS reset stylsheets, these stylesheets will reset each elements precisely

Set the padding and margin top/bottom of the <p> tag to 0. <p> tags automatically have a default padding/margin set, in case you dont overwrite it by something else.

p {
   margin: 0;
   padding: 0;
}

p stands for paragraph. the paragraph automaticly adds space like this: Fiddle

and you can remove it like this: fiddle

I can't tell you what your problem is, but from this fiddle: http://jsfiddle.net/u6C9E/

p { margin: 0; padding: 0; }

works.

If you have any image above and/or bottom of the paragraphs, make the paragraphs in two class.

HTML:

<p> class="first">Your 1st Paragraph</p>
<p> class="second">Your 2nd Paragraph</p>

The CSS :

    p.first {
        text-indent: 2em;
        margin-bottom: -5%;
    }
    p.second {
        margin-top: -5%;
        text-indent: 2em;
    }

Use "%" to let it still looking good in responsive web...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!