HTML Notes Updated
HTML Notes Updated
1. Introduction to HTML
HTML (HyperText Markup Language) is the foundational language for creating web pages. It allows
HTML uses tags (keywords surrounded by angle brackets < >) to identify different types of content.
Tags often come in pairs like <tagname> and </tagname>, with the first tag in the pair being the
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
Explanation:
- <!DOCTYPE html>: This declaration defines the document type and version of HTML being used
- <html>: This is the root element of the HTML page. All other elements are nested within it.
- <head>: Contains meta-information about the document such as the title, character set, and links
to stylesheets or scripts.
- <title>: Sets the title of the webpage, which is displayed on the browser tab.
- <body>: This is where the visible content of the webpage is placed. Text, images, links, and other
elements go here.
- <h1>: Represents a top-level heading. HTML supports multiple levels of headings, from <h1>
3.1 Headings
HTML provides six levels of headings, <h1> to <h6>, where <h1> is the highest or most important
Example:
<h1>This is an H1 Heading</h1>
<h2>This is an H2 Heading</h2>
<h3>This is an H3 Heading</h3>
3.2 Paragraph
The <p> tag defines a paragraph of text. Browsers automatically add some space (margin) before
Example:
3.3 Links
The <a> tag is used to create hyperlinks. The href attribute specifies the URL of the page the link
goes to.
Example:
3.4 Images
The <img> tag is used to embed images. It requires the src attribute to define the image source
(URL or path) and the alt attribute for alternate text (useful for accessibility).
Example:
3.5 Lists
Example:
<ol>
<li>First item</li>
<li>Second item</li>
</ol>
Example:
<ul>
<li>First item</li>
<li>Second item</li>
</ul>
3.6 Tables
Example:
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</table>
Explanation:
4. Attributes
Attributes provide additional information about HTML elements. They are always included in the
Common Attributes:
Example:
<h2 id="section1">This is a Heading with an ID</h2>
- class: Specifies one or more class names for an element, which can be used to style elements with
CSS.
Example:
Example:
Example:
Example:
5. HTML Semantics
Semantic HTML elements clearly describe their meaning in a human- and machine-readable way.
Example:
<header>
<h1>My Website</h1>
</header>
Example:
<nav>
<a href="#home">Home</a>
<a href="#about">About</a>
</nav>
Example:
<section>
<h2>Section Title</h2>
<p>This is a section.</p>
</section>
Example:
<article>
<h2>Article Title</h2>
<p>This is an article.</p>
</article>
Example:
<footer>
<p>Copyright © 2024 My Website</p>
</footer>
6. Multimedia
6.1 Images
Example:
6.2 Audio
Example:
<audio controls>
</audio>
6.3 Video
Example:
HTML forms are used to collect user inputs and send them to a server.
Example:
<label for="name">Name:</label>
<br>
<label for="email">Email:</label>
<br>
</form>
8. HTML Entities
HTML entities are special characters that cannot be easily typed or have reserved meanings in
HTML.
Examples:
- : Non-breaking space
9. HTML5 Features