Category: 

What Is HTML Syntax?

Article Details
  • Written By: Eugene P.
  • Edited By: Angela B.
  • Last Modified Date: 14 November 2017
  • Copyright Protected:
    2003-2017
    Conjecture Corporation
  • Print this Article

HyperText Markup Language (HTML) syntax is the formal definition of what words have meaning to the language interpreter and the way in which they need to be arranged and written to be correctly interpreted. For the most part, basic HTML syntax is made from words that are enclosed in greater-than and less-than signs, with the entire bracketed sequence being known as a tag. Each tag can contain only a single word, can be a pair of tags marking the start and end of a block of text or other elements, or can even contain multiple attributes separated by spaces, such as the name of an image, or a class definition. HTML syntax is fairly loose compared to other programming languages, because basic HTML is intended to be a markup language used to provide formatting to documents, although some more complex extensions to HTML, such as cascading style sheets (CSS), have a far more structured syntax.

Ad

HTML syntax is designed so tags can be inserted into a text document to provide formatting or links or to insert images that can be seen when the document is parsed by an HTML viewer, such as a web browser. For this reason, HTML tags are defined as being encased in the greater-than and less-than signs to distinguish them from the rest of the text in the document. Additionally, because the HTML code is intended to markup, or modify, the appearance of text in the document, most tags surround the text they are modifying.

This can be seen with the basic HTML tag for bolded text. The text that is going to be displayed in bold is surrounded by two tags, with the first simply containing the letter B in brackets, and the ending tag containing a forward slash and the letter B in brackets. The forward slash in HTML syntax indicates that a tag is a closing tag, meaning it will end a block that was previously started with the opening version of the same tag. With very few exceptions, most HTML tags consist of opening and closing tag pairs.

Other elements that comprise HTML syntax include the tags used to actually define the properties of an HTML document. These tags usually are placed at the beginning of an HTML document and specify options such as the type of character encoding used, special display features such as right-to-left character display for some languages, or even information on any special content included in the file. Proper HTML syntax also includes how attributes within a tag are listed, how some tags can appear — because not all can be nested inside of others — and even ways to include comments for the developer that will not be displayed when a page is viewed.

One complication that often occurs with the use of HTML syntax is that some non-standard, technically unsupported syntaxes end up becoming widely used. This can occur when an HTML viewer or web browser attempts to make it possible to view HTML documents that do not follow proper syntax, and instead automatically compensate and show the page. This has caused some syntactical rules, such as including closing tags for certain markups, to be commonly disregarded, despite being part of the formal HTML syntax.

Ad

Recommended

Discuss this Article

Post your comments

Post Anonymously

Login

username
password
forgot password?

Register

username
password
confirm
email