The HTML Elements
HTML document is built using elements. Elements are the bricks that create the structure that hold a web page together. Elements give structure to html document and tells the browser how you want your website to be displayed, for example, a <p> informs the browser to make a paragraph <h1> for heaning 1 just like word processing.
- An HTML element starts and ends with tags
- A tag consists of an opening angled bracket <,> the opening tag, some text, and a closing bracket <⁄> closing tag. You put the element content inside the start and the end tag.
- Inside a tag, there is a tag name; there may also be one or more attributes. Example, <img src"images/eric.jpg" />
- Some HTML elements have empty content, example <br />, <hr />
Example of HTML Tags in my website:
- Attributes provide additional information about HTML elements.
- HTML elements can have attributes
- Attributes are always specified in the start tag
- Attributes come in name/value pairs like: name=“value”
Attributes are always written within a start tag and are followed by an equals sign and the attribute details written between the double quotes (“attribute name”). The semicolon after the attribute is for separating different style commands.
<a href=“http://www.desena.com.au”>Desena web design<⁄a> Href is the name of the attributes and the http://www.desena.com.au is the value of the attributes. Attribute values should always be enclosed in double quotes.
Empty HTML Elements
HTML elements with no content are called empty elements. <br /> is an empty element without a closing tag (the <br ⁄>, tag defines a line break). Horizontal rule <hr ⁄>. Images - <img src=”eric.jpg” alt=”eric” width=”300” height=”250” ⁄>, meta element is also a self-closing element.
All HTML elements must be closed. Adding a slash inside the start tag, like <p⁄>, is the proper way of closing empty elements in HTML.