Page 159 - HTML5
P. 159

Chapter 41: Void Elements


        Introduction

        Not all HTML tags are of the same structure. While most elements require an opening tag, a
        closing tag, and contents, some elements - known as void elements - only require an opening tag
        as they themselves do not contain any elements. This topic explains and demonstrates the proper
        usage of void elements in HTML


        Remarks

        A void element cannot have any content but may have attributes. Void elements are self-closing,
        so they must not have a closing tag.

        In HTML5, the following elements are void:

            •  area
            •  base
            •  br
            •  col
            •  embed
            •  hr
            •  img
            •  input
            •  keygen
            •  link
            •  meta
            •  param
            •  source
            •  track
            •  wbr

        Examples


        Void elements

        HTML 4.01/XHTML 1.0 Strict includes the following void elements:

            •  area - clickable, defined area in an image
            •  base - specifies a base URL from which all links base
            •  br - line break
            •  col - column in a table [deprecated]
            •  hr - horizontal rule (line)
            •  img - image
            •  input - field where users enter data
            •  link - links an external resource to the document
            •  meta - provides information about the document
            •  param - defines parameters for plugins

        HTML 5 standards include all non-deprecated tags from the previous list and

            •  command - represents a command users can invoke [obsolete]
            •  keygen - facilitates public key generation for web certificates [deprecated]
            •  source - specifies media sources for picture, audio, and video elements
        The example below does not include void elements:


         <div>
             <a href="http://stackoverflow.com/">
                 <h3>Click here to visit <i>Stack Overflow!</i></h3>



        https://riptutorial.com/                                                                             143
   154   155   156   157   158   159   160   161   162   163