HTML elements and attributes

HTML elements (also known as HTML tags) are simply the HTML main key words that are used in between angle brackets, such as: <p>...</p>, <h1>...</h1>, <h2>...</h2>, <em>...</em>, <span>...</span>, <br />, <img />, etc.

Invalid HTML elements include tags such as: <font>, <b>, <i> because they define how the content should look like: this should be left for the css.

The attributes are defined within an HTML element in order to qualify them. The name of the attribute is always followed by an equal sign and the value of the attribute is placed in between double quotes. E.g. here is the element <p> with the attribute class which has for value "introduction": <p class="introduction" >...</p>. The list of available attributes depends on the element and can be found with any online HTML reference. Here are a few examples:

  • attribute "class": <span class="author">...</span>
  • attribute "id": <h2 id="menu-42" >...</h2>
  • attribute "href": <a href="/node/42" >...</a>
  • attribute "title" and "src": <img src="/images/test.png" title="test image" />
  • Note: CSS can be defined within an HTML element as an attribute thereof. For this, we use the attribute "style". The value of the "style" attribute is actual CSS code: <p style="text-indent: right;"> ...</p>. This is called (I think) inline CSS declaration

Invalid attributes include align, color, width etc. because they define how the element should look like: this definition should be left to the css.