Hello dear readers! Today, as a continuation of the series of articles under the heading "Basics of html", I want to acquaint you with the algorithm for creating html lists with help tags ul and li (unordered list), ol and li (numbered list), dl, dt, dd (definition list).
Now I will continue to acquaint you with the most frequently used html tags, which are used to create lists on site pages. If someone does not know what it is, surely after the information received below, they will immediately understand what it is about, since this form of presentation of the material is very common.
HTML bulleted lists - ul and li tags
The bulleted list is defined by the ul tag. List items are located between the opening and closing ul tags, the content of each of which must in turn be located between the opening and closing li tags. Immediately, I note that the ul tag is paired (the presence of an opening and closing tags), as well as block, that is, it forms a container that contains elements (strings) formed each time by the li tag. Accordingly, the li tag is paired and lowercase.
Default appearance marker is represented by a filled circle. However, you can change its appearance by applying the type attribute, which has the following values: disc, circle, square. The disc value (which determines the appearance of the filled circle marker) is the default. That is, if the type attribute is not specified, the appearance of the marker will look like a filled circle. If we add these attributes to the ul tag, we get the following options:
Naturally, each marker of an individual item in the bulleted list can be given its own appearance by writing the appropriate values \u200b\u200bfor the type attribute.
Numbered HTML Lists - ol and li tags
Now let's see how a numbered list is formed using ol tags (block and paired tags, similar to ul). The li tag also acts as a tag that defines the elements of the numbered list of html. A numbered list is a collection of numbered items. The type of numbering is determined by the type attribute, which can take the following values:
- A - capital Latin letters;
- a - lowercase Latin letters;
- I - capital Roman numerals;
- i - lowercase Roman numerals;
- 1 - Arabic numerals
|
|
|
|
|
|
|
|
|
|
You can also provide a numbered list where the items are numbered in reverse order, for example: 3, 2, 1. This is done using the reserve attribute of the ol tag.
It is also possible to start a bulleted list with any other number instead of 1. To do this, you can use the start attribute, and it does not matter at all what value of the type attribute is set. See an example of using the name attribute in conjunction with the different values \u200b\u200bfor the type attribute (1 and I):
HTML definition lists - dl, dd, dt tags
Another kind of html lists is a definition list. It is formed as follows. The content of this list is enclosed between the opening and closing dl tags that form the container. The dt tag defines a term, and dd is the description of that term.
As you can see, the content of the dt tag, which is a term, is shifted to the left, and the content of the dd tag, which is the definition of this term, is written in italics. All this is achieved by using various css styles, which we will certainly talk about in upcoming publications.
By the way, modern realities are such that the html language cannot be considered apart from, therefore, in order not to miss these important materials, subscribe to the blog update via RSS feed or by e-mail. This concludes the topic of today's article, if you received necessary information, don’t refuse to use the social media buttons.
Good day!
In this article, you will learn about all the possibilities of lists, understand how to make a numbered list, master tags that will help make a simple bulleted list more interesting and noticeable with arbitrary bullets. After completing the lesson, you will have an understanding of where lists are used and under what circumstances they can be used.
This article is the third in this short tutorial on basic HTML. Before reading this lesson, I recommend going through the previous two:
The article has just begun, and you may already notice the use of a standard bullet list. On my website, it looks quite simple: on the left there is a small indent with a line and a square marker. Further in the article, we will take a closer look at what markers are, how to make numbers, and also how to make your own marker.
In each part of the article, the creation of certain lists will be accompanied by detailed explanations for inserting a particular list.
1. Bulleted lists in HTML
This type of lists is used to list a set of elements similar in meaning in the text. This can be a listing of links that are related to the same topic, a detailed explanation for individual parts of the text. But let's see how bulleted lists look like in the code:
And this is how it looks in the browser:
Figure: 1.1. Standard view of HTML bulleted unordered list in browser1.1 Standard bullet points
In the image above (Figure 1.1.), You can see circles at the beginning of each menu item. This is the marker. By default, it is a filled circle in the browser. There are several types of markers in HTML: filled circle, empty circle, and square. They do not require CSS or third-party images:
1.2 List marker as an empty circle
You know the attribute values, but now let's see how to make an HTML bulleted list in the code. From the table above, we have selected the second value "circle" for the type attribute and assigned it to our bulleted list:
<html\u003e <head\u003e <title\u003eAn example of a bulleted list with an empty circle marker</ title\u003e </ head\u003e <body\u003e <p\u003eStars:</ p\u003e <ul type \u003d "circle"\u003e <li\u003eSirius</ li\u003e <li\u003eArcturus</ li\u003e <li\u003ePollux</ li\u003e <li\u003eBetelgeuse</ li\u003e <li\u003eThe sun</ li\u003e </ ul\u003e </ body\u003e </ html\u003e |
Let's see how this code will look in the browser:
Figure: 1.2. Bullet view for a list in the form of a circle in the browser1.3 List marker in the form of a square
Let's also see the last example with a square bullet for HTML list:
Notice the marker, it has become square:
Figure: 1.3. Marker view for a square list in a browserImportant note: this is no longer used for styling bulleted lists. There is a clear separation between CSS (read what CSS is) and HTML. HTML is for markup and CSS is for creating an attractive look.
The code that contains this attribute, when specifying the type of the current document as HTML5 (""), will give an error during validation. If you have not heard what validation is, then you should go here -.
The error will be as follows:
Figure: 1.4. Error on the validator when using the "type" attribute of the listWe figured out the bulleted lists. Now let's move on to numbered, and then consider nested lists and a few ready-made examples that are most often used on real sites.
2. Numbered lists in HTML
Unlike the previous type of lists, numbered lists have one important feature: they automatically add numbering. This is useful when you need to number big list... It will take a very long time manually, and you can still get lost. A numbered list is specified using a tag. How it looks in practice:
An example of a numbered list:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <html\u003e <head\u003e <title\u003eExample of a standard numbered list</ title\u003e </ head\u003e <body\u003e <p\u003eOne to five:</ p\u003e <ol\u003e <li\u003eFirst</ li\u003e <li\u003eSecond</ li\u003e <li\u003eThird</ li\u003e <li\u003eFourth</ li\u003e <li\u003eFifth</ li\u003e </ ol\u003e </ body\u003e </ html\u003e |
This is how a numbered list looks like with standard settings in the browser:
Figure: 2.1. Numbered list in a browser with standard settingsLike its predecessor (bulleted list), it has its own styles for displaying numbers. Plain numbering is not the only kind of bullets for a numbered list in HTML.
2.1 Standard bullets for a numbered list
Here we have a choice not of three types of markers, but of five:
Marker name | The value of the "type" attribute | List example |
---|---|---|
Arabic numeral markers | 1 |
|
Markers in the form of lowercase Latin letters | a |
|
Markers in the form of capital Latin letters | A |
|
Lowercase Roman Numerals | i |
|
Uppercase Roman numerals | I |
|
2.2 Custom numbering in the HTML list
In addition to the usual output of a numbered list, we can also start our numbering from any digit. To do this, you must set the additional "start" attribute. This numbering works for all types of bullets for numbered lists. How it looks in practice:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <html\u003e <head\u003e <title\u003eRandom numbering for a numbered list</ title\u003e </ head\u003e <body\u003e <p\u003eWe start numbering at twelve:</ p\u003e <ol type \u003d "a" start \u003d "12"\u003e <li\u003eTwelve</ li\u003e <li\u003eThirteen</ li\u003e <li\u003eFourteen</ li\u003e <li\u003eFifteen</ li\u003e <li\u003eSixteen</ li\u003e </ ol\u003e </ body\u003e </ html\u003e |
This is how it will display on a live site:
Figure: 2.2. Numbering from an arbitrary number in a numbered listIn the image above, we have numbered the list starting from twelve, while making the markers in the form of lowercase Latin letters. Now, I think, it became clear how to use these attributes in your projects.
For now, let's move on to nested HTML lists.
3. How to make a multilevel (nested) list in HTML
Multilevel lists are used on the site in building the menu. This menu most often looks like a dropdown either down (lesson on), or dropdown to the left or right. Such menus allow you to store other menu items in a compact form.
Using car models as an example, we will build a multilevel list in HTML:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <html\u003e <head\u003e <title\u003eHTML nested bulleted list</ title\u003e </ head\u003e <body\u003e <ul\u003e <li\u003eCitroen<ul\u003e <li\u003eBerlingo</ li\u003e <li\u003eC1</ li\u003e <li\u003eC2</ li\u003e <li\u003eC3 Picasso</ li\u003e <li\u003eC4 Grand Picasso</ li\u003e </ ul\u003e </ li\u003e <li\u003eKIA</ li\u003e <li\u003eToyota</ li\u003e <li\u003eAudi</ li\u003e <li\u003eLexus</ li\u003e </ ul\u003e </ body\u003e </ html\u003e |
Notice what a multilevel list looks like in a browser:
Figure: 3.1. Example of a multilevel list in HTMLWe made a multilevel list using a bulleted (tag
- ). The tiered list with Citroen models came with other markers. The main list with filled bullets, and the 2nd level list with empty circles. But, remember, with the "type" attribute we can override the markers (it's better to set them).
- marked with a marker,
numbered list —- - each element of the list
- marked with a number,
definition list - - consists of term pairs- —
- definition.
Each list is a container that contains list items or term-definition pairs. List items behave like block items, stacking one under the other and taking up the entire width of the container block. Each list item has additional blocklocated on the side that does not participate in the layout.
Generating HTML Lists
1. Bulleted list
Bulleted list is an unordered list (from the English Unordered List)... Created using a paired tag
... The marker of a list item is a label, for example, a filled circle.Browsers add the following formatting to the list box by default:
Each list item is created using a pair tag
- (from the English List Item).
- available.
- Microsoft
- Apple
2. Numbered list
Numbered list is created using a paired tag. Each list item is also created using the element
- marked with a number,
- ... The browser numbers the elements in order automatically, and if you delete one or more elements of such a list, the rest of the numbers will be automatically recalculated.
The list box also has default browser styles:
- the value attribute is available, which allows you to change the default number for the selected list item. For example, if for the first item in the list you set
- , then the rest of the numbering will be recalculated relative to the new value.
For tag
- the following attributes are available:
- Microsoft
- Apple
- and
- available.
- Producer:
- Petr Tochilin
- Cast:
- Andrey Gaidulyan
- Alexey Gavrilov
- Vitaly Gogunsky
- Mariya Kozhevnikova
Figure: 3. List of definitions
4. Nested list
Often, the capabilities of simple lists are not enough, for example, when creating a table of contents, you cannot do without nested items... The markup for the nested list would be as follows:
- Paragraph 1.
- Point 2.
- Subclause 2.1.
- Subclause 2.2.
- Subclause 2.2.1.
- Subclause 2.2.2.
- Subclause 2.3.
- Point 3.
Figure: 4. Nested list
5. Multilevel numbered list
A layered list is used to display list items at different levels with different indents. The markup for a multilevel numbered list would be as follows:
- paragraph
- paragraph
- paragraph
- paragraph
- paragraph
- paragraph
- paragraph
- paragraph
- paragraph
- paragraph
- paragraph
This default markup will create a new numbering starting with one for each nested list. To make nested numbering, you need to use the following properties:
counter-reset resets one or more counters, setting a value to reset;
counter-increment specifies the counter increment value, i.e. with what step each subsequent item will be numbered;
content - the generated content, in this case it is responsible for displaying the number before each item in the list.Ol (/ * remove the standard numbering * / list-style: none; / * Identify the counter and name it li. The counter value is not specified - by default it is 0 * / counter-reset: li;) li: before (/ * We define the element to be numbered - li. The pseudo-element before specifies that the content inserted using the content property will be placed before the list items. It also sets the counter increment value (default is 1). * / Counter-increment: li; / * The content property displays the number of the list item counters () means that the generated text is the value of all counters with that name. A quoted period adds a separating period between numbers, and a period with a space is added before the contents of each list item * / content: counters (li, ".") ".";)
Figure: 5. Multilevel numbered list
Table 1. Tag Attributes
Attribute Description, accepted value reversed The reversed attribute displays the list in reverse order (for example, 9, 8, 7 ...). start The start attribute sets the initial value from which the numbering will start, for example, the construction - the first item will be assigned a serial number "10". You can also specify the numbering type at the same time, for example,
- .
type The type attribute specifies the kind of marker to use in the list (as letters or numbers). Accepted values:
1 - default value, decimal numbering.
A - numbering the list in alphabetical order, capital letters (A, B, C, D).
a - numbering the list in alphabetical order, lower case (a, b, c, d).
I - numbering in Roman capital numerals (I, II, III, IV).
i - Roman numeration lowercase numbers (i, ii, iii, iv).3. List of definitions
Definition lists are created using the tag
The definition list box has the following default browser styles:
For tags
- ,
- Item # 1
- Item # 2
- Item # 3
- ...
- Item # 1
- Item # 2
- Item # 3
- Item # 1
-
- Item # 2-1
- Item # 2-2
- Item # 2-3
- Item # 3
- ...
- Item # 1
- Item # 2
- Item # 1
- Item # 2
- Item # 1
- Item # 2
- Item # 1
- Item # 2
- ...
- disc - a marker in the form of a circle (the example was above)
- circle - marker in the form of a transparent circle (the example was above)
- square - a marker in the form of a square (the example was above)
- decimal - marker in the form of a numbered list in Arabic numerals: 1, 2, 3, ...
- decimal-leading-zero - marker in the form of a numbered list in Arabic numerals with leading zero: 01, 02, 03, ...
- lower-roman - marker in the form of a numbered list in the Roman alphabet in small letters: i, ii, iii, iv, v
- upper-roman - bullet in the form of a numbered list in the Roman alphabet in big letters: I, II, III, IV, V
- lower-latin - a marker in the form of a list in the Latin alphabet in small letters: a, b, c, d, ...
- upper-latin - a marker in the form of a list in the Latin alphabet in capital letters: A, B, C, D, ...
- lower-greek - a bullet in the form of a list in the Greek alphabet in small letters
- upper-greek - bullet in the form of a list in the Greek alphabet in capital letters
- ... When setting an attribute to a tag
- all list items will be displayed as the attribute indicates. But we can set our own mapping to this or that element. Example in the picture:
- Item # 1
- Item # 2
- Item # 3
- Item # 1
- Item # 2
- Item # 3
- Item # 1
- Item # 2
- Item # 3
- Item # 1
- Item # 2
- Item # 3
- Combining pieces of information into a single structure to give a readable look.
- Description of complex step-by-step processes.
- The location of information in the style of a table of contents, the paragraphs of which indicate the corresponding sections of the document.
- (LI - List Item). Tag
- does not need an appropriate end tag, although its presence is in principle not forbidden. Browsers usually start each new list item on a new line when displaying a document.
The information provided is enough to build an elementary bulleted list. Here is an example of an HTML document using a bulleted list, which is displayed by the browser in Fig. 2.1.
Bullet List Example - Aries
- calf
- Twins
- Crayfish
- a lion
- Virgo
- Libra
- Scorpio
- Sagittarius
- To the lake
- Aquarius
- Fish
Zodiac signs:
Figure: 2.1. Browser Display Bulleted List
Note that in addition to the list items marked with the tag
- , other HTML elements may be present. In the above example, one of these elements is plain text, which is not a list item but serves as its heading.
Note
Some HTML textbooks instruct you to use a tag container to set the title of the list
(LH - List Header, list header). This tag is currently not recognized by any of the mainstream browsers and is not part of the HTML specification. Thus, its application becomes meaningless, although it will not lead to any errors. In tag
- two parameters can be specified: COMPACT and TYPE.
- .
Recording example:
-
.
Note
Browsers have different interpretations for specifying a bullet type for an individual list item. The Netscape browser changes the type of marker for this and all subsequent ones until it encounters another override of the marker type. Internet browser Explorer changes marker view only for of this element.
Graphic list markers
Graphics can be used as list markers, which is widely used to create attractive, beautifully designed HTML documents. In fact, such a possibility is not provided directly by HTML, but is implemented somewhat artificially. This does not mean that it is not recommended or reprehensible to do so, but only means that no special HTML language constructs will be used here.
To understand the idea, you need to understand how lists are implemented in HTML pages. It turns out that the list tag
- (as well as tags of other types of lists, discussed below) performs the only task - it tells the browser that all information located after this tag should be displayed with a shift to the right (indented) by some amount. Tags
- that point to individual list items provide standard list item markers.
If we need to build a list with graphic markers, then we can do without tags altogether.
- ... It will be enough to insert the desired graphic image before each element of the list. The only task that needs to be solved in this case will be to separate the elements of the list from each other. You can use paragraph tags for this
Or forced line feed
... An example of the implementation of a list with graphic markers, the display of which is shown in Fig. 2.2 is shown below:Bulleted list Zodiac signs:
Aries
calf
Gemini
Pak
Lev
Virgo
Libra
Scorpio
Sagittarius
Capricorn
Aquarius
Fish
Figure: 2.2. Bullet list with graphic markers
In the above example, the list item marker is graphic file Green_ball.gif. Note that using graphics on HTML pages can significantly increase the amount of information transferred. However, in this case, this increase is extremely insignificant. Here, the same file is used for all markers,
which will only be transmitted once. The size of the file containing small imageare also extremely insignificant.
Note
Methods for creating lists with graphic markers are discussed in turn in Chapter 8.
Numbered list
Another type of lists implemented in HTML is a numbered list. Otherwise, lists of this type are called ordered. The latter name is often used as a formal translation of the name of the corresponding tag.
- , with the help of which lists of this type are organized in HTML documents (OL - Ordered List).
- .
Here is an example of an HTML document using a numbered list, whose display browser is shown in Fig. 2.3.
Example of a numbered list - Sirius
- To anopus
- Arcturus
- Alpha Centauri
- Vega
- K apella
- Rigel
- Procyon
- Achernar
- Beta Centauri
- Vetelgeuse
- Aldebaran
. . .- Mizar
. . .- Polar
The brightest stars visible from Earth:
Figure: 2.Z.Numbered list
In tag
- the following parameters can be specified: COMPACT, TYPE and START.
- .
Recording example:
- .
Parameter START tag
- allows you to start numbering a list from a non-one. A natural number must always be specified as the value of the START parameter, regardless of the type of list numbering. Let's give an example:
- for numbered lists, allows the TYPE and VALUE parameters to be used. The TYPE parameter can take the same values \u200b\u200bas for the tag
- .
- .
Note
Browsers interpret specifying the type of numbering for an individual list item differently. The Netscape browser changes the numbering for this element and all subsequent ones, until it encounters another override. Internet Explorer changes the appearance of the number for this item only.
Zthe value of the VALUE tag
- - allows you to change the number of this list item. This also changes the numbering of all subsequent elements. Typical applications are lists with omitted items. An example of such a list was given above (Fig. 2.3). It gives an ordered list of the brightest stars, in which at 58 and 75 places are stars that are clearly visible in our latitudes (Mizar is the brightest star in the constellation Ursa Major, and Polaris is Ursa Minor).
Here is another original example of using different types of numbering. The following HTML code contains three lists with different numbering. For ease of viewing, each of the lists is placed in a separate cell of the table. All three lists are identical and differ only in the type of numbering: in the first column of the table - Arabic numerals, in the second - Roman, and in the third, numbering is with Latin letters... Note that the list items are empty, that is, after any tag
- no data available. An example of this kind can be used as a table of correspondence between the recording of numbers in Arabic and Roman numerals. It turns out that any browser that supports lists can be used as a generator for such a table (Figure 2.4), as long as you type in the HTML below. Roman numerals work correctly up to 3999. By examining the right column, you can understand how the Roman numerals are numbered. When the one-letter numbering (from A to Z) is exhausted, the first two-letter number is taken as the next number - AA, etc.
Using different types of numbering in lists -
. . .
-
. . .
-
. . .
Figure: 2.4.Different types of HTML list numbering
Definition list
Lists of definitions, also called vocabularies of definitions of special terms, are a special kind of lists. Unlike other types of lists, each element of a definition list always has two parts. The first part of the list item contains the term being defined, and the second part contains the text in the form of a dictionary entry that reveals the meaning of the term.
Definition lists are specified using a container tag
- (Definition List). Inside the container with the tag
- (Definition Term) marks the term being defined, and the tag
- (Definition Description) - a paragraph with its definition. For tags
- and
- you do not have to write the corresponding end tags.
In general, the definition list is written as follows:
- Term
- Definition of the term
In the text after the tag
- block level elements such as paragraph tags cannot be used
Or headlines
-
... Typically, the text of the term being defined should be on one line. The text containing the definition of a term is displayed starting on the next line (or across a line for some browsers) after the definition of the term, indented to the right. In the information placed after the tag
- , block-level elements can be located. This implies, in particular, that definition lists can be nested.
In tag
- the COMPACT parameter can be specified, the purpose of which is similar to the other lists described above.
- Phlegmatic person
- Passive, very capable of working, slowly adapting;
the mood is stable, little amenable to external influence;
lethargy of emotional reactions and slowness in volitional activity
- Sanguine
- Active, energetic, easily adaptable, -
liveliness and mobility of emotional reactions, speed and strength of volitional manifestations
- Choleric
- Active, very energetic, persistent;
impetuosity and strength of emotional reactions, violent volitional manifestations
- Melancholic
- Passive, easily tired, difficult to adapt, -
weakness of volition and the predominance of a depressed mood, self-doubt - Zempia
- Moon
- Mapc
- Phobos
- Deimos
- Uranus
- Ariel
- Umbriel
- Titania
- Oberon
- Miranda
- Neptune
- Triton
- Nereid
Here's an example of an HTML document that uses a definition list:
An example of a definition list Classification of typical human temperaments,
foundedon the views of Hippocrates
The display of the given HTML document in the browser is shown in Fig. 2.5.
Figure: 2.5. List of definitions (resembles a group of entries in a dictionary)
Type Lists
and - .
Initially, lists of these types were conceived as more compact than conventional bulleted lists. According to the rules for writing the elements of these lists, it was not allowed to use block elements in them, which means that it is impossible to implement nesting of lists of this type. Each item in the list was one line of text.
For lists like
it was planned to introduce a restriction on the “text length of a list item (24 characters). Such a limitation would allow the derivation lists like
in a form similar to the listing of directories in operating systems UNIX and MS-DOS when using the / W switch (in multiple columns). In addition, markers were not displayed for list items of this type. At present, all these ideas have not been implemented, since the further use of lists of these types is not recommended. Modern versions of browsers display lists of these types completely similar to lists of the type
- .
Nested lists
There are times when a list item of one type needs to include an entire list of the same type or another. This will organize multilevel or nested lists. HTML allows arbitrary nesting of various types of lists, but care should be taken when organizing them.
Below is the HTML code of the document with nested lists, the display of which is shown in Fig. 2.6. In this example, each item in the bulleted list has its own numbered list.
Example of a nested list Satellites of some planets
- , block-level elements can be located. This implies, in particular, that definition lists can be nested.
-
Pexample of recording:
- .
- .
Such an entry determines the numbering of the list from the capital Latin letter "E". For other types of numbering, the entry START \u003d 5 will set the numbering, respectively, from the number "5", the Roman numeral "V", etc.
It is permissible to change the type of numbering of the list and the values \u200b\u200bof numbers for any element of the list. Tag
- for numbered lists, allows the TYPE and VALUE parameters to be used. The TYPE parameter can take the same values \u200b\u200bas for the tag
The COMPACT parameter has the same meaning as bulleted lists. The TYPE parameter is used to set the type of list numbering. It can take the following values:
TYPE \u003d А - sets markers in the form of uppercase Latin letters;
TYPE \u003d a - specifies markers in the form of lowercase Latin letters;
TYPE \u003d I - sets markers in the form of large Roman numerals;
TYPE \u003d i - specifies markers in the form of small Roman numerals;
TYPE \u003d 1 - specifies markers in the form of Arabic numerals.
The default is always tYPE value \u003d 1, that is, numbering using Arabic numerals. This also applies to nested numbered lists. Here, unlike bulleted lists, browsers by default do not make different numbering at different levels of nesting of the lists. Note that after the number of the list item, an additional "dot" is always displayed.
The TYPE parameter with the same values \u200b\u200bcan be used to specify the style of numbering individual list items. For this, the TYPE parameter with the corresponding value is allowed to be specified in the tag of the list item
Lists of this type usually represent an ordered sequence of individual elements. The difference from bulleted lists is that in a numbered list each element is automatically preceded by a sequential number. The numbering type depends on the browser and can be set by the parameters of the list tags. Otherwise, the implementation of numbered lists is very similar to the implementation of bulleted lists.
Tags
- and
To create a numbered list, use a tag container that contains all the list items. The start and end tags of a list provide line feeds before and after the list, thus separating the list from the main content of the document.
As with a bulleted list, each item in a numbered list must begin with the tag
- that point to individual list items provide standard list item markers.
The COMPACT parameter is written with no values \u200b\u200band is used to tell the browser that this list should be output in a compact form. For example, the font or the distance between the lines of the list can be reduced, etc.
Note
Currently, the presence of the COMPACT parameter in the tag
- does not in any way affect the display of lists by leading browsers. Therefore, the use of this parameter is meaningless, especially since its use is not recommended by the HTML 4.0 specification.
The TYPE parameter can take the following values: disc, circle and square. This parameter is used to force the appearance of the list markers. The exact type of marker will depend on the browser used. Typical display options are as follows:
TYPE \u003d disc - markers are displayed with filled circles; TYPE \u003d circle - markers are displayed with open circles; TYPE \u003d square - markers are displayed with filled squares. Recording example:
-
.
The default is TYPE \u003d disc. For nested bulleted lists, the default is disc at the first level, circle at the second, and square at the third and beyond. This is exactly what is done in latest versions Netscape browsers and Internet Explorer... Note that other browsers may display markers differently. For example, the HTML 4.0 specification specifies a square outline for the marker appearance displayed when TYPE \u003d square.
The TYPE parameter with the same values \u200b\u200bcan be used to specify the type of markers for individual list items. For this, the TYPE parameter with the corresponding value is allowed to be specified in the tag of the list item
- .
The code looks like this:
Changing tag markers
- with CSS
Bulleted List Items Created by Tag
- , can be marked with arbitrary images. CSS is used to change the marker type. for example
And this is how it looks on the page:
C using CSS we can define other types of marker display. But you need to remember that when setting any style for the tag
- , it applies to all elements of the list.
IN hTML language a special set of tags is provided for presenting information in the form of lists. Lists are one of the most commonly used forms of data presentation as in electronic documentsand in print. We meet with lists almost every day - it can be a list of necessary purchases in the store, students in the classroom, or just things that need to be done. The ability to organize list structures is available in many text editorsparticularly powerful word processor Microsoft Word has convenient formatting tools for various types of lists (the possibilities of creating HTML lists using Microsoft Word are discussed in Chapter 8). Here are a number of cases for which the use of lists is quite convenient:
Note that the above items are organized in the form of a list structure.
HTML provides the following basic types of lists: bulleted, numbered, and list of definitions. To implement lists different types the following tags are used:
- ,
- ,
- ,
, - , with the help of which lists of this type are organized in HTML documents (UL - Unordered List, unordered list).
A bulleted list uses special symbols, called list markers (often called bullets, which is the formal pronunciation of the English term bullet). The type of list markers is determined by the browser, and when creating nested lists, browsers automatically diversify the look of markers at various levels of nesting.
Tags
- and<LI\u003e
To create a bulleted list, you need to use a tag-container, inside which all the elements of the list are located. The opening and closing list tags provide line feeds before and after the list, thus separating the list from the main content of the document, so there is no need to use paragraph tags here
.Each element of the list must begin with a tag
But we can combine multilevel lists with numbered and bulleted lists like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | <html\u003e <head\u003e <title\u003eNumbered, Bulleted, and Multilevel Lists in HTML</ title\u003e </ head\u003e <body\u003e <ul\u003e <li\u003eThe first group of tulips<ol\u003e <li\u003eFirst grade<ul\u003e <li\u003eSimple early tulips</ li\u003e </ ul\u003e </ li\u003e <li\u003eSecond class<ul\u003e <li\u003eTerry tulips</ li\u003e </ ul\u003e </ li\u003e </ ol\u003e </ li\u003e </ ul\u003e </ body\u003e </ html\u003e |
In the example above, we have double nesting (2 levels). First, we put in a list of two classes of tulips, we have it numbered. Then a bulleted list is nested into each of the items in the numbered list.
We look at its appearance in the browser:
Figure: 3.2. Example of a multilevel numbered list into a bulleted list in a browser4. Useful Resources for HTML Lists
It contains information that requires an understanding of CSS properties. To do this, I recommend studying the following lessons:. All examples will be immediately with source code and are broken down into HTML (structure), CSS (styles) and Result (result) tabs.
4.1 How to make an HTML list into a string
You may need to make the HTML list into a string when creating a horizontal menu. It's very simple to make it:
4.2 How to make an HTML list without an icon
The list-style-type property in CSS is responsible for this (more details):
4.3 How to make a list in HTML centered
A list item is a block item, so it needs to be centered with padding. But there is one important point - we must explicitly specify the width for the alignment to work:
4.4 How to make a list in HTML with pictures
Just one CSS property list-style-image is enough. Inside url, specify the address before the icon. I just want to note that it is better to select a small image right away, because the height of the list line depends on it:
4.5 HTML Bulleted List Your Marker
In this case, you must first connect font icons (for example, FontAwesome). Then you can make any icon instead of the standard marker:
4.6 How to make a list in HTML into multiple columns
To make a multi-column list we will use the CSS column-count property (this property is only supported in the following browsers: IE 10+, Chrome 1.0+, Opera 11.1+, Safari 3.0+, Firefox 1.5+). You also need to set the height for the list to see the split into multiple columns:
5. Practice of working with lists
In the video below you can see all the work with hTML lists on practice:
HTML lists are used to group related pieces of information together. There are three types of lists:
bulleted list —
- - each element of the list
The hypertext markup language HTML has a tag
- used to create bulleted lists. It is supported by all modern browsers and allows elements to be displayed in a non-numbered order. For example, it very often displays menu items and everything related to the lists on the page: dishes, products, equipment, tools and much more that needs to be listed without indicating the priority of one or another item.
Tag syntax
This code is converted to a bulleted list on the site:
Tag
- requires the mandatory use of an end tag
A pair tag is used to form list items. Between the opening and closing tags are individual words, phrases, paragraphs, images, chunks of code and much more, which are the contents of a bulleted list.
What can be the contents of a bulleted list?It can be a variety of texts, including single words, phrases and paragraphs, images, nested lists, chunks of php code, and much more that needs simple labeling.
Each bulleted list item is indented by default 40 pixels to the right. Using cSS styles, we can change the display of this list at our discretion. Tag
- is block-based, so it occupies the entire area available to it, limited by the edge of the screen, table frame, or other page elements.
List-in-list attachments are allowed
for example
Tag attributes and properties
Widely used tag attribute
- is a type attribute that indicates how the list marker will look like. Can take the following values
1. type \u003d "disc" - marker in the form of a filled circle (this value is the default). The disk example was just above.
2. type \u003d "circle" - a marker in the form of a transparent circle
For example:
3. type \u003d "square" - a marker in the form of a square
For example:
And this is how it looks on the page:
In CSS, the marker type is specified using the list-style-type attribute:
Let's consider what values \u200b\u200bthe list-style-type can take:
Note 2
The attribute can be assigned as the tag itself
- and tags