What happens if I directly add the li without adding the ul


#1

What happens if I directly add the li without adding the ul


FAQ: Learn HTML Elements - Intro to HTML - Unordered Lists
FAQ: Learn HTML Elements - Intro to HTML - Unordered Lists
#2

I noticed that creating a list using “li” tags but without the “ul” tag still results in a listed format. But I also found that adding the “ul” tag results in the list becoming indented, while removing it causes the list to appear flush left. So is the function of the “ul” tag more a visual organizer, like “div”, or a formatting tool? Or both? (If someone could also explain how to format a comment so the tags appear properly, I would appreciate it! Can’t seem to figure that out).


#3

The main purpose in using the designated containers is for validity and structure. LI is essentially a DIV with the same ability to contain other block level elements, including tables. We do not expect to see the element outside of a specified container. They have an intended use, with organization being a possible consideration, but not formatting.

HTML is not a presentational language. It is a structural, declarative language aimed at giving meaning to textual content and other media We never choose an element for how it will appear, visually, but for where it appears in the document outline.

```html
Code here
```

Browsers are very good these days at filling in missing bits in order to parse something that can be rendered. When <li> appears in the wild with no <ul>, <ol> or <menu> container, the browser may well fall back to a UL. However, it does not have licence to apply default UL, OL, or MENU styles. Given only an LI, those are the only default styles that can be applied.


#4

Very helpful, thank you!