HTML Material
What is HTML?
HTML stands for HyperText Markup Language.
It’s the standard language used to create and design web pages.
HTML defines the structure and content of web pages using elements and tags.
Basic Structure of an HTML Document
An HTML document typically consists of the following elements:
1. <!DOCTYPE html>: Declares the document type and version of HTML. For HTML5,
it's simply <!DOCTYPE html>.
2. <html>: The root element that contains all the content of the page.
3. <head>: Contains meta-information about the document, like the title, character set,
and links to stylesheets.
4. <title>: Specifies the title of the page, which appears in the browser tab.
5. <body>: Contains the content of the web page, including text, images, links, etc.
Basic HTML Tags and Elements
Headings:
Use headings to define titles and subtitles. There are six levels, <h1> being the largest.
Paragraphs:
Paragraphs are used to define blocks of text.
Links:
Links are created with the <a> tag and use the href attribute to define the URL.
Images:
Images are inserted with the <img> tag, using src for the image path and alt for
alternative text.
Lists:
Ordered List:
Used for numbered lists.
Unordered List:
Used for bullet-point lists.
Tables:
Tables are used to display data in rows and columns.
Attributes
HTML elements can have attributes that provide additional information about an element.
Attributes are always written in the opening tag:
href specifies the URL.
target="_blank" opens the link in a new tab.
HTML Forms
Forms are used to collect user input:
<form>: Wraps the input elements.
<input>: Collects user data.
HTML Entities
Special characters in HTML are represented by entities, such as:
< for <
> for >
& for &
Comments
HTML comments are added with <!-- and -->:
Comments are not displayed in the browser but can be used to annotate code.
Best Practices
Always use semantic HTML tags (like <header>, <footer>, <article>) to give
meaning to the content.
Ensure your HTML is well-structured and properly indented for readability.
Validate your HTML code to avoid errors and ensure compatibility.