Warning:
This wiki has been archived and is now read-only.

Educational materials/Tag syntax

From HTML Wiki
Jump to: navigation, search

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

  1. it starts with <
  2. then a list of characters without space, the tagname (or element)
  3. ends usually with a >.

Then closing the simple element with a end tag

  1. it starts with </
  2. then the same list of characters without space, the tagname (or element)
  3. 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.

These are examples of syntaxes you might see on the Web:

<!-- empty attributes -->
<input disabled>
<input disabled="">
<input disabled=""/>

<!-- attributes with a value -->
<input name=address>
<input name='address'>
<input name="address">


See also 8.1.2 Elements.

Syntax error

See also 1.9.2 Syntax error


The next content is Create HTML.
Let's create HTML document.