Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use list-style-type to div tag?

Tags:

css

list

I have been studying CSS. I know that we can use list-style-type attribute to set list marker. Can we apply that attribute to a div tag?

like image 285
user2732006 Avatar asked Sep 04 '13 10:09

user2732006


People also ask

Can we use style in DIV tag?

The <div> tag defines a division or a section in an HTML document. The <div> tag is used as a container for HTML elements - which is then styled with CSS or manipulated with JavaScript. The <div> tag is easily styled by using the class or id attribute. Any sort of content can be put inside the <div> tag!

Can a list item be a div?

Yes, you can. As much as you want.

Which of the following Cannot be the value of list style type?

Which of the following can't be the value of list-style-type? Explanation: list-style-property is used for defining the style of list item marker. Its value can be square, circle, disc or none. For setting list item marker to be bullet we use the value disc.


2 Answers

Yes you can. The following causes a div tag to resemble itself like a list item:

div {display:list-item;} 
like image 125
Nitesh Avatar answered Sep 21 '22 02:09

Nitesh


You can set any CSS property on any HTML element. In fact, an element always has all the CSS properties (with the defined initial value as the value, if not set). Not all properties have an effect on all elements in all circumstances, though.

In particular, the definition of the list-style-type property says: “Applies to: elements with 'display: list-item'”. Here “applies to” means “has an effect on rendering of”.

Moreover, even if you set display: list-item on a div, there will be no list marker (like a bullet or a number) to be seen, unless there is space on the left of the element content to accommodate it. You can arrange space using margin properties. Example:

div {   display: list-item;   margin-left: 1.3em;   list-style-type: circle;    } 
like image 22
Jukka K. Korpela Avatar answered Sep 20 '22 02:09

Jukka K. Korpela