HTML/Training/Tag syntax

Tag syntax

HTML is using tags for its syntax. A tag is composed with special characters: <, > and /. They are interpreted by softwares to compose an HTML element.

Decomposition of HTML elements

HTML Elements comes usually by tag pairs.

For opening a simple element with a start tag

it starts with <

then a list of characters without space, the tagname (or element)

ends usually with a >.

Then closing the simple element with a end tag

it starts with </

then the same list of characters without space, the tagname (or element)

ends usually with a >.

If the tagname is "cite", then you get

<cite></cite>

Some elements do not have an end tag (because they are implied by the following tags). For example you might have seen.

<br>

An element can have attributes to refine its meaning.

These attributes are specified on the start tag. They consist of a name and a value, separated by an "=" character. Such as:

<tagname attribute="value"></tagname>

In HTML, the attribute value can remain unquoted if it doesn't contain spaces or any of the following characters: " ' ` = < or >. Otherwise, it has to be quoted using either single or double quotes. The value, along with the "=" character, can be omitted altogether if the value is the empty string. Once you are working in a team you might want to choose a common way of authoring your code.