HTML stands for HyperText Markup Language. It is the standard language used to create and design webpages.
HTML is more flexible with syntax rules, while XHTML adheres to stricter XML rules. XHTML requires well-formed documents, including closed tags and lowercase element names.
<div>
, <p>
, <a>
, etc.<tagname>content</tagname>
.id
, class
, src
, etc.Tags define the structure and content of HTML elements. E.g., <p>
, <div>
. Attributes provide additional information about an HTML element. E.g., <img src="image.jpg" alt="Description">
.
The syntax of an HTML tag is:
<tagname attribute="value">Content</tagname>
<tagname>
attribute="value"
</tagname>
An attribute
provides additional information about an element and is written within the opening tag of the element. Attributes usually come in name-value pairs: name="value"
.
class
, id
, style
).onclick
, onmouseover
).src
for <img>
, href
for <a>
).Block-Level Elements start on a new line and take up the full width available (e.g., <div>
, <p>
, <h1>
). Inline Elements do not start on a new line and take up only as much width as necessary (e.g., <span>
, <a>
, <strong>
).
A hyperlink
is created using the <a>
tag and allows users to navigate from one page to another. Example:
<a href="https://www.example.com">Visit Example</a>
https://www.example.com/page
)./page
or page.html
).A mailto
link opens the default email client to send an email. Example:
<a href="mailto:example@example.com">Email Us</a>
The <img>
tag is used to embed images in a webpage. Example:
<img src="image.jpg" alt="Description of image">
An HTML table
displays data in rows and columns. Example:
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</table>
<table>
: Container for the table.<tr>
: Table row.<th>
: Table header cell.<td>
: Table data cell.An HTML form
collects user input. Example:
<form action="/submit" method="post">
<label for="name">Name:</label>
<input type="text" id="name" name="name">
<input type="submit" value="Submit">
</form>
<input type="text">
<input type="password">
<input type="checkbox">
<input type="radio">
<select>
<button>
<textarea>
allows multiple lines of input.<input type="text">
allows single-line input.An HTML list
organizes items into a list format. There are two main types:
<ol>
): Numbered list.<ul>
): Bulleted list.<ol><li>Item 1</li></ol>
).<ul><li>Item 1</li></ul>
).**HTML headings** are used to define headings on a webpage. There are six levels of headings:
<h1>
: Most important heading.<h2>
: Second level.<h3>
: Third level.<h4>
: Fourth level.<h5>
: Fifth level.<h6>
: Least important heading.An HTML paragraph
is defined by the <p>
tag and represents a block of text.
The <span>
tag is used for inline styling or grouping text within a block-level element.
The <div>
tag is used for grouping block-level elements and applying styles or scripts.
<span>
: Inline container for styling or scripting.<div>
: Block-level container for grouping larger sections.
<div class="myClass">
). Used for grouping similar elements.<div id="uniqueId">
). Used for unique element identification.The alt
attribute provides alternative text for images when they cannot be displayed. It improves accessibility and SEO.