Main Content
- Main (
<main>
):Represents the dominant content of the
<body>
of a document.Example:
2024-10-31
HTML: The Building Blocks of the Web
HTML stands for HyperText Markup Language.
Key Points:
<p>This is a paragraph.</p>
<h1>
and </h1>
<ul><li>Item 1</li><li>Item 2</li></ul>
<img src="image.jpg" alt="Description">
This is a simple web page created using HTML.
<!DOCTYPE>
, <html>
, <head>
, and <body>
tags.<!DOCTYPE html>
:
<html>
:
<html lang="en">
lang
attribute specifies the language of the document.<head>
<head>
:The <head>
section of an HTML document contains meta-information about the document, such as its title, character encoding, and links to external resources like stylesheets.
<meta charset="UTF-8">
: Specifies the character encoding.<meta name="viewport" content="width=device-width, initial-scale=1.0">
: Ensures responsive design.<meta name="description" content="A simple HTML example">
: Provides a description for search engines.<title>
: Sets the title of the document, displayed in the browser tab.<link rel="stylesheet" href="styles.css">
: Links to an external CSS file.<body>
The <body>
section of an HTML document contains all the content that is displayed to the user, such as headings, paragraphs, images, and links.
This is a simple HTML page to demonstrate the structure of a web document.
<h1>
, <h2>
, <h3>
, <h4>
, <h5>
, <h6>
<h1>
is the main heading, and <h6>
is the least important heading.<p>
Use the target="_blank"
attribute to open the link in a new tab.
Example:
Use the mailto:
scheme in the href
attribute to create a link that opens the user’s email client.
Example:
Use the tel:
scheme in the href
attribute to create a link that initiates a phone call on supported devices.
Example:
<img>
src
attribute to specify the image’s source.alt
attribute to provide an alternative text description for accessibility.Organizing Data with HTML Tables
HTML tables are used to present data in a structured format, with rows and columns. They are often used for displaying tabular information such as schedules, data comparisons, or product catalogs.
Key Elements:
<table>
: Defines the table.<thead>
: Contains the table header row.<tr>
: Defines a table row.<th>
: Defines a table header cell.<tbody>
: Contains the table body rows.<td>
: Defines a table data cell.Product Name | Price | Quantity |
---|---|---|
Laptop | $999 | 10 |
Smartphone | $799 | 20 |
Tablet | $499 | 15 |
colspan
: Specifies how many columns a cell should span.rowspan
: Specifies how many rows a cell should span.border
: Sets the width of the table border. <table border="1">
<tr>
<th colspan="2">Header 1</th>
<th rowspan="2">Header 2</th>
</tr>
<tr>
<td>Row 1, Cell 1</td>
<td>Row 1, Cell 2</td>
</tr>
<tr>
<td colspan="3">Row 2, Cell 1 (spans 3 columns)</td>
</tr>
</table>
Header 1 | Header 2 | |
Row 1, Cell 1 | Row 1, Cell 2 | |
Row 2, Cell 1 (spans 3 columns) |
<ul>
):
Creates a list of items with bullet points.
Example:
<ol>
):
Creates a list of items with numbers.
Example:
<li>
):
<div>
):
Group elements together for styling or layout purposes.
No semantic meaning.
Example:
<header>
):
Contain page-level navigation or branding.
Example:
<footer>
):
Contain page-level information, such as copyright or contact details.
Example:
<main>
):
Represents the dominant content of the <body>
of a document.
Example:
<section>
):
Represents a standalone section of content.
Example:
<article>
):
Represents a self-contained composition in a document, page, or site.
Example:
<aside>
):
Represents content that is tangentially related to the content around it.
Example:
<nav>
):
Represents a section of a page that links to other pages or to parts within the page.
Example:
<figure>
):
Represents self-contained content, such as illustrations, diagrams, photos, code listings, etc.
Example:
<figcaption>
):
Represents a caption or legend for a figure.
Example:
<summary>
):
Represents a summary, caption, or legend for the content of a <details>
element.
Example:
<details>
):
Represents a disclosure widget from which the user can obtain additional information or controls.
Example:
Use descriptive and keyword-rich content.
Ensure proper use of HTML tags for better indexing.
Examples:
<h1>Main Title of the Page</h1>
<h2>Subheading with Keywords</h2>
<p>This is a descriptive paragraph that includes relevant keywords to improve search engine ranking.</p>
<a href="https://www.example.com" title="Example Website with Keywords">Visit Example Website</a>
<img src="image.jpg" alt="Descriptive Alt Text for Image">
Use semantic HTML tags (e.g., <header>
, <footer>
, <article>
, <section>
) to structure content.
Ensure all images have descriptive alt
attributes.
Use meaningful and keyword-rich URLs.
Include meta tags for title and description.
Ensure the website is mobile-friendly and has a fast loading time.
<header>
, <main>
, <section>
, <article>
, <footer>
.<title>
, <meta charset>
, <meta name="description">
, <meta name="keywords">
, <meta name="author">
.E. Bruno