What’s HTML syntax?

Print anything with Printful



HTML syntax consists of tags enclosed in greater-than and less-than signs, used to provide formatting to documents. It also includes tags for defining document properties and attributes. Non-standard syntax is sometimes used due to browser compensation.

HyperText Markup Language (HTML) syntax is the formal definition of what words have meaning to the interpreter of the language and how they must be arranged and written to be interpreted correctly. For the most part, basic HTML syntax consists of words enclosed in greater-than and less-than signs, with the entire sequence in parentheses known as tags. Each tag can contain only a single word, can be a pair of tags that mark the beginning 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 definition class. HTML syntax is quite free compared to other programming languages, because basic HTML is intended as a markup language used to provide formatting to documents, although some more complex extensions of HTML, such as cascading style sheets (CSS), have a much more structured syntax.

HTML syntax is designed so that tags can be inserted into a text document to provide formatting or links, or to insert images that can be viewed when the document is parsed by an HTML viewer, such as a web browser. For this reason, HTML tags are defined as enclosed in greater than and less than signs to distinguish them from other text in the document. Also, since HTML code is intended to mark up or change the appearance of text in your document, most tags surround the text they’re changing.

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

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

One complication that often occurs with the use of HTML syntax is that some non-standard and technically unsupported syntax ends up becoming widely used. This can occur when an HTML viewer or web browser tries to make it possible to view HTML documents that do not follow the correct syntax and instead compensates and automatically displays the page. This has caused some syntactic rules, such as including closing tags for certain markup, to be commonly ignored, despite being part of formal HTML syntax.




Protect your devices with Threat Protection by NordVPN


Skip to content