What is HTML?
HTML (HyperText Markup Language) is the standard language used to create web pages. It provides the structure for web content, such as headings, paragraphs, images, links, and more. HTML documents are plain text files with tags that define the elements of the page.
Basic Structure of an HTML Document
An HTML document is made up of tags, which are enclosed in angle brackets. Here's the basic structure of an HTML document:
Explanation:
<!DOCTYPE html>
: This declaration defines the document type and version (HTML5 in this case).<html>
: This is the root element that contains the entire document.<head>
: Contains meta-information about the document like character set, title, and links to stylesheets or scripts.<meta charset="UTF-8">
: Specifies the character encoding for the document.<meta name="viewport" content="width=device-width, initial-scale=1.0">
: Makes the page responsive on mobile devices.<title>
: Sets the title of the webpage, which appears in the browser tab.<body>
: Contains the visible content of the webpage, such as text, images, and links.
Common HTML Elements
Here are some commonly used HTML tags:
Headings
HTML has six levels of headings,<h1>
to<h6>
, with<h1>
being the largest.Paragraphs
Use the<p>
tag for paragraphs of text.Links
The<a>
tag is used to create hyperlinks. Thehref
attribute defines the destination URL.Images
Use the<img>
tag to embed images. Thesrc
attribute defines the image file, andalt
provides alternative text.Lists
HTML supports ordered and unordered lists.Unordered List (bullets):
Ordered List (numbered):
Tables
Use<table>
,<tr>
,<th>
, and<td>
to create tables.Forms
HTML forms are used to collect user input. Here's a simple form with a text input and a submit button:
HTML Attributes
Attributes provide additional information about HTML elements. They are always written within the opening tag of an element.
- class: Specifies one or more class names for an element (used for styling with CSS).
- id: Specifies a unique identifier for an element.
- href: Specifies the URL for a link.
- src: Specifies the source file for images or videos.
- alt: Provides alternative text for images.
- style: Adds inline CSS styling to an element.
Example of using attributes:
HTML Forms and Inputs
Forms are essential for gathering user data, such as text inputs, checkboxes, radio buttons, and submit buttons.
HTML5 Features
HTML5 introduced several new features, such as:
Audio & Video
HTML5 includes native support for embedding audio and video.Canvas
The<canvas>
element allows for drawing graphics via JavaScript.Local Storage
HTML5 allows storing data locally in the browser.
Conclusion
This is just an overview of HTML's basic structure and some common elements. As you dive deeper, you'll learn about more advanced topics like:
- CSS for styling HTML elements
- JavaScript for adding interactivity
- Semantic HTML elements like
<header>
,<footer>
,<article>
, and<section>
If you want to get hands-on, you can start creating simple HTML pages and gradually experiment with more complex structures.
No comments:
Post a Comment