KandZ – Tuts

We like to help…!

HTML – 2 Elements

Introduction to HTML elements

What is an element

What is a tag

What is an element attribute

2. Elements

  • an element has an opening tag, attributes, content and a closing tag (show h1 heading)
  • opening tag closing tag
  • Hello world -> content
  • Don’t forget to close an element, always use the closing tag for the element
  • elements can contain other elements (show body element)
  • empty elements donot have content
  • W3C recommends lowercase in HTML
  • element attributes gives more information about it. They are optional
  • the attributes are written inside the opening tag
  • an attribute have a name and a value
  • there are 4 attribute categories
    • universal attributes that can be used in almost all elements
    • specific attributes than can be used in specific element
    • event attributes that are used to trigger an event
    • data attributs to store information
  • Universal attributes
    • id indentifies an element id=”example”
    • class assign an element to a class class=”cars”
    • style defines the style for the eleement style=”color: blue; font-size: 2em”
    • title appears on mouse hover title=”exampletext”
    • lang defines the language
    • dir defines text’s direction dir=”ltr” or rtl

Leave a Reply