HTML Tag - Usage, Attributes, Examples - W3docs
Có thể bạn quan tâm
The HTML <ul> tag is used for specifying an unordered list, which groups a collection of items having no numerical order. When changing the order of list items, the meaning does not change. Usually, the items of an unordered list are displayed with a bullet. It can be of different forms such as a circle, a dot, or a square.
Each element of an unordered list is declared inside the <li> tag.
The <ul> tag is a block-level element, and occupies all available horizontal space. Its height depends on the content within the container. An unordered list is typically rendered as a bulleted list.
The <ol> tag also represents a list of items and creates an ordered list. But it differs from <ul>, as the order in the <ol> tag is meaningful. By default, the items of an ordered list are displayed with numbers.
The <ul> and <ol> tags can be nested as deeply as you want. The nested lists can alternate between <ul> and <ol>. However, you should consider that in case of nesting a list inside another, the first list should be presented as a list element (
It is possible to change the list item marker with CSS. However, the semantic meaning expressed by the choice of a list type cannot be changed with CSS.
Syntax
The <ul> tag comes in pairs. The content is written between the opening (<ul>) and closing (</ul>) tags.
Example of the HTML <ul> tag:
<!DOCTYPE html> <html> <head> <title>Title of the document</title> </head> <body> <ul> <li>List item</li> <li>List item</li> <li>List item</li> </ul> </body> </html> Try it Yourself »Result
You can use type attribute to change the default bullet style for the list items.
Example of the HTML <ul> tag with the type attribute:
<!DOCTYPE html> <html> <head> <title>Title of the document</title> </head> <body> <ul type="circle"> <li>List item </li> <li>List item</li> <li>List item</li> </ul> <ul type="square"> <li>List item</li> <li>List item</li> <li>List item</li> </ul> </body> </html> Try it Yourself »You can also use CSS list-style-type or list-style-image property to define the type of a list item element.
Example of the HTML <ul> tag used with the CSS list-style-type property:
<!DOCTYPE html> <html> <head> <title>Title of the document</title> </head> <body> <h2>Examples of unordered lists:</h2> <ul style="list-style-type: square"> <li>Cold Drinks</li> <li>Hot Drinks</li> <li>Ice-Creams</li> </ul> <ul style="list-style-type: disc"> <li>Coca-Cola</li> <li>Fanta</li> <li>Ice Tea</li> </ul> <ul style="list-style-type: circle"> <li>Coca-Cola</li> <li>Fanta</li> <li>Ice Tea</li> </ul> </body> </html> Try it Yourself »Attributes
Attribute | Value | Description |
---|---|---|
compact | compact | Specifies that the list should be rendered in a compact style. Not supported in HTML 5. |
type | discsquarecircle | Sets the type of marker. Not supported in HTML 5. |
The <ul> tag also supports the Global attributes and the Event Attributes.
How to style <ul> tag?
Common properties to alter the visual weight/emphasis/size of text in <ul> tag:
- CSS font-style property sets the style of the font. normal | italic | oblique | initial | inherit.
- CSS font-family property specifies a prioritized list of one or more font family names and/or generic family names for the selected element.
- CSS font-size property sets the size of the font.
- CSS font-weight property defines whether the font should be bold or thick.
- CSS text-transform property controls text case and capitalization.
- CSS text-decoration property specifies the decoration added to text, and is a shorthand property for text-decoration-line, text-decoration-color, text-decoration-style.
Coloring text in <ul> tag:
- CSS color property describes the color of the text content and text decorations.
- CSS background-color property sets the background color of an element.
Text layout styles for <ul> tag:
- CSS text-indent property specifies the indentation of the first line in a text block.
- CSS text-overflow property specifies how overflowed content that is not displayed should be signalled to the user.
- CSS white-space property specifies how white-space inside an element is handled.
- CSS word-break property specifies where the lines should be broken.
Other properties worth looking at for <ul> tag:
- CSS text-shadow property adds shadow to text.
- CSS text-align-last property sets the alignment of the last line of the text.
- CSS line-height property specifies the height of a line.
- CSS letter-spacing property defines the spaces between letters/characters in a text.
- CSS word-spacing property sets the spacing between words.
Từ khóa » Html5 Ul Tag
-
HTML Ul Tag - W3Schools
-
- : The Unordered List Element - HTML - MDN Web Docs - Mozilla
-
HTML
- Tag - GeeksforGeeks
-
HTML 5
- Tag
-
HTML Unordered List | HTML Bulleted List - Javatpoint
-
HTML:
- Tag - TechOnTheNet
-
HTML5
- Tag, Example Of
- Tag In Html 5 - RoseIndia.Net
-
- HTML Tag »
-
» - HTML">
- » - HTML
-
HTML -
- Tag - Tutorialspoint
-
HTML5
- Tag - HTML Doctor
-
- Tag In HTML - Scaler Topics
-
HTML: The Ul, Ol, And Li Tags - Khan Academy
-
- Tag - TutorialBrain