Is a list containing only one child element really a list? Is this false semantics?

When I hear the list, I expect there will be more than one item.

Is this really a problem? Am I just semantically anal?

<h3>Search Results</h3>
<ul>
    <li><a href="??">only one result</a></li>
</ul>

Does one element of a list of child elements really not look like such a list? Has anyone else thought about this too?

+3
source share
7 answers

I think it can be said that a single-element list is still a list.

You might want to consider the list not only in terms of what it has, but also in terms of what it is allowed to have.

+4
source

0 elements are invalid, 1 or more elements are valid

! - W3 Validator.
, XHTML, !

:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
   <title>Doc title</title>
   <meta http-equiv="content-type" content="application/xhtml+xml;charset=utf-8" />
   <meta http-equiv="content-style-type" content="text/css" />
 </head>
 <body>
   <div>

    <h3>List with no items</h3>
    <ul>
    </ul>
    <h3>List with one item</h3>
    <ul>
        <li>Only one</li>
    </ul>
    <h3>List with two items</h3>
    <ul>
    <li>One</li>
    <li>Two</li>
    </ul>

   </div>
</body>

</html>

:

: 1

  • 15, 5: "ul",

    </ >

    , . e < > < & EM GT;... </ > , <em> <p> . :   < > < & EM GT;... </& GT; </ >

    , , , . , " ", . , HTML , (ul, ol, dl) (li, dt, dd) ..

, , "you used an element which requires a child element that you did not include"

!

+3

( ) . "" ?

+2

, , []:

  • ...

"-" ( ) , ?

, , ...

+2

, ( , ). 1 0 , . , . . , , , , 0. , . . / . . , 2 , , . "" .

+1
source

Both in the terminal definition and in the form of a data type, a list can have only one element.

(Where would you start?))

0
source

The list may contain empty, 1 or more items. In your case

<!-- empty unordered list -->
<ul>
</ul>

<!-- unordered list contains 1 element -->
<ul>
    <li><a href="??">only one result</a></li>
</ul>
-1
source

Source: https://habr.com/ru/post/1721952/


All Articles