Reduce Gap between HTML <UL> and <LI> elements

你离开我真会死。 提交于 2019-12-05 08:37:47

The gap does not exist between UL and LI elements, but between the Forum text and the UL element. Most browsers define a default margin around certain elements, like the UL.

You get rid of it with CSS:

ul { margin: 0; }

or if you just want to reduce it, for example this one will set 0 margin for horizontal, 5px for vertical:

ul { margin: 5px 0; }

Try this (don't know if it's the problem with you):

<ul><li>
your first li element </li><li>
your second li element</li>
</ul>

There are spaces that you can't avoid on HTML code if you don't "avoid" it, let's say. Take a look here.

Andrew

In addition to kapa's comment, if you enter a negative value for the margin it will reduce the gap.

In css:

ul { margin:-20px;}

Yes, you can use CSS. In your CSS, specify the margin or padding properties to adjust the spacing between your LI and UL elements.

LI { margin: 0px; }

This will decrease the vertical distance, but not the horizontal.

ul { margin:-15px 0;}

It is a combination of Andrew and kapa's.

Here's how it looks.

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