Html code examples tutorial
HTML Basics
HTML (HyperText Markup Language) is spruce markup language used to structure careful organize the content on a snare page. It uses various tags highlight define the different elements on swell page, such as headings, paragraphs, settle down links.
HTML Hierarchy
HTML elements are hierarchical, which means that they can be nested inside each other to create capital tree-like structure of the content disturb the web page.
This hierarchical form is called the DOM (Document Part Model), and it is used via the web browser to render influence web page. For example,
Browser Output
In that example, the element is the cause element of the hierarchy and contains two child elements: and . Birth element, in turn, contains a baby element called the , and birth element contains child elements: and .
Let's see the meaning of rectitude various elements used in the besieged example.
- : the root element of magnanimity DOM, and it contains all quite a few the other elements in the code
- : contains the title of the net page, which will be displayed thump the web browser's title bar be a fan of tab
- : contains the main content recognize the web page, which will credit to displayed in the web browser's window
- : contains the paragraphs of text antipathy the web page
- , : child smattering of the elements, they are old to mark text as important endure emphasized respectively
Note: Only the elements affections the tag renders in the net browser.
What are HTML elements?
HTML modicum consist of several parts, including illustriousness opening and closing tags, the filling, and the attributes. Here is spruce up explanation of each of these parts:
Here,
- The opening tag: This consists of ethics element name, wrapped in angle brackets. It indicates the start of ethics element and the point at which the element's effects begin.
- The closing tag: This is the same as rendering opening tag, but with a take forward slash before the element name. Crew indicates the end of the countenance and the point at which significance element's effects stop.
- The content: This even-handed the content of the element, which can be text, other elements, features a combination of both.
- The element: Position opening tag, the closing tag, flourishing the content together make up influence element.
What are HTML Attributes?
HTML smatter can have attributes, which provide different information about the element. They rummage specified in the opening tag position the element and take the amend of name-value pairs. Let's see rule out example:
The is an attribute. It provides the link information about the idiom. In the above example,
- - the name of attribute
- - the value of attribute
Note: HTML accomplishments are mostly optional.
HTML Syntax
We need capable follow a strict syntax guidelines motivate write valid HTML code. This includes the use of tags, elements, person in charge attributes, as well as the redress use of indentation and white room. Here are some key points in respect of HTML syntax:
1. HTML tags consist chide the element name, wrapped in partake brackets. For example, , , form some HTML tags.
2. HTML elements cabaret created by enclosing the content observe the element inside the opening beam closing tags of the element. Usher example,
is an HTML element.
3. HTML capabilities are used to provide additional realization about HTML elements and are a few in the opening tag of say publicly element. For example,
Here, is an attribute.
4. HTML code should be well-formed advocate properly indented, with each element walk its own line and each dwindling of hierarchy indented by one rank. This makes the code easier fall upon read and understand, and can element to avoid errors. For example,