Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where do the bullets come from on <li> elements?

Tags:

html

css

My current understanding is that different HTML elements are separated in their functionality by their default CSS styling, semantics aside.

Using custom CSS, you could (inadvisably) make any HTML element behave like any other.

If that is correct, the only thing I cannot account for is the bullets on <li> elements. What CSS causes them? How can you add that to other elements?


Note to future readers: I recently learned HTML elements also differ by content categories.

like image 394
temporary_user_name Avatar asked May 05 '15 20:05

temporary_user_name


People also ask

How do you add bullets to Li?

First, place the <ul>… </ul> tags around the text to turn into a bulleted list. Second, place the <li>… </li> tags around each line item in the list.

How do you remove bullets from UL and Li?

HTML exampleAdding the "list-style: none" CSS class to the unordered list (<ul>) or ordered list (<ol>) tag removes any bullet or number.

Which element will create a bullet list?

<ul>: The Unordered List element. The <ul> HTML element represents an unordered list of items, typically rendered as a bulleted list.

How do you tag a Li without a bullet?

To create unordered list in HTML, use the <ul> tag. Unordered list starts with the <ul> tag. The list item starts with the <li> tag and will be marked as disc, square, circle, none, etc.


1 Answers

The bullets are contained "within" the padding of <ul> element:

The padding is marked green and the margin orange:

1

Decreasing the padding shows that the bullets are "within" that padding:

4

Increasing the margin of the <ul> for example, shifts it right.

2

The list-style property controls the bullets themselves. Setting it to none will hide them. You would need to set the margin and padding to 0 if you want to get rid of the indent too.

ul {     list-style: none; } 

3

If you want to get rid of all margins / paddings and the bullet points, use this:

ul {     list-style: none;     margin: 0;     padding: 0; } 

5


Of course you can also apply bullets to other HTML controls:

div {     padding-left: 40px; } a {     display: list-item;     list-style: disc; }
<div>     <a href="#">Item #1</a>     <a href="#">Item #2</a>     <a href="#">Item #3</a>     <a href="#">Item #4</a> </div>
like image 160
bytecode77 Avatar answered Sep 17 '22 15:09

bytecode77