Home

The Syntax and Rules of HTML5

|
|  Updated:  
2016-03-26 14:02:47
HTML5 and CSS3 All-in-One For Dummies
Explore Book
Buy On Amazon

HTML is called a markup language for a very good reason: It grabs ordinary, normal text and inserts various strings into that text to define, organize, and manage the flow and sequence of content on web pages.

The inserted strings define the markup, which web browsers — or other special programs known as user agents — pore over and use (along with CSS, of course) to guide their display of the content included.

Like any language, HTML is subject to a specific syntax, which defines the order in which markup must or can appear in a web page. There are also lots of interesting rules about what kinds of markup is legal in certain places but illegal in others. This may seem like a difficult concept, but these restrictions in HTML illustrate what this means and why it makes very good sense:

  • The element is for providing a caption for a table. Thus it can appear only inside

    markup. If you want to provide a caption for a figure, you must use the
    element instead. You need to employ the right markup for the right uses in HTML.
  • HTML recognizes various kinds of lists, which can organize text items with numbers or bullets, as the markup directs. List items employ the

  • tags to identify individual items in such lists. That’s why those particular tags are legal only if they occur within some kind of list element, such as
      (an unordered, or bulleted list) or
        (an ordered, or numbered list).

      1. HTML supports all kinds of fields and input controls for online forms. As with tables, forms-related elements can appear only inside a pair of
        tags.

        There are lots of forms-related elements and attributes that can appear only in such a context. These include numerous input types, various kinds of text boxes, button controls, and more. All of them are legal only in a form, so they must occur between
        and on a web page if they are to work.

      2. Understanding HTML largely boils down to grasping how to create the markup it uses (that’s the syntax) and understanding the order (or context) in which individual markup elements may appear.

        Those are the rules for creating valid or legal HTML. The same observations are true for CSS also, by the way, except that the syntax and the rules for its expression are different because CSS is a different markup language from HTML.

      About This Article

      This article is from the book: 

      About the book author:

      Ed Tittel is a 28-year veteran of the computer industry. A seasoned author and consultant, Ed has more than 140 books to his credit.

      Chris Minnick is an accomplished author, teacher, and programmer. Minnick authored or co-authored over 20 books, including titles in the For Dummies series. He has developed video courses for top online training platforms and he teaches programming and machine learning to professional developers at some of the largest global companies.