Introduction to HTML 5
HTML 5 Basics
HTML 5 is the latest version of the HyperText Markup Language (HTML) standard, used to create web pages and web applications. It's designed to be more semantic, modular, and accessible, making it easier to create powerful and engaging web content.
HTML 5 Basics
HTML 5 is the latest version of the HyperText Markup Language (HTML) standard, used to create web pages and web applications. It's designed to be more semantic, modular, and accessible, making it easier to create powerful and engaging web content.
Editor Notepad++
Notepad++ is a free and popular text editor for Windows. It offers syntax highlighting, code completion, and other features that make it a useful tool for writing HTML code.
Doctype, Title, Meta, Body
Every HTML document starts with a Doctype declaration, which informs the browser about the document's type. Then, the <html> element acts as the root element, containing a <head> and a <body>.
- <head>: Holds information about the HTML document, such as the title, meta information, and links to external resources (stylesheets, scripts).
- <title>: Defines the title of the HTML document, which is displayed in the browser's title bar or tab.
- <meta>: Provides meta information about the HTML document, such as character set, keywords, description, and viewport settings.
- <body>: Contains the content of the HTML document, including text, images, videos, and other elements that will be displayed on the webpage.
<!DOCTYPE html>
<html>
<head>
<title>My HTML Document</title>
<meta charset="UTF-8">
</head>
<body>
<p>This is my first HTML document!</p>
</body>
</html>
Tags and Elements
In HTML, tags are keywords enclosed in angle brackets, like <p> and </p>. They define elements, which represent different parts of an HTML document. Elements usually have a start tag and an end tag, but some elements are self-closing (e.g., <img>). The content between the start and end tags is the element's content.
Example: <p>This is a paragraph.</p> defines a paragraph element with the text "This is a paragraph."
Attributes
Attributes are used to provide additional information about HTML elements. They appear within the start tag and are defined as name-value pairs, separated by an equal sign. Attributes can be used to control the appearance, behavior, or meaning of an element.
Global Attributes
Global attributes can be applied to all HTML elements. Some common global attributes include:
- id: Unique identifier for an element.
- class: Group elements with the same style or behavior.
- title: Provides a tooltip for the element.
- style: Sets inline styles for an element.
- lang: Specifies the language of the element's content.
- dir: Sets the text direction (left-to-right or right-to-left).
Element Specific Attributes
Each HTML element has its own set of specific attributes. These attributes control the behavior or appearance of that specific element. For example, the <img> element uses the "src" attribute to specify the image's source, and the <a> element uses the "href" attribute to define the link's destination.
Comments
Comments are ignored by the browser and are used to add notes or explanations to the HTML code. They are written between <!-- and -->.
<!-- This is a comment -->
Do You Know?
HTML 5 introduces new semantic elements that provide more meaning to the content. These elements include <article>, <aside>, <nav>, <footer>, and <header>. These elements help search engines understand the structure of your web pages better.
Avoid This
Don't forget to close your HTML tags properly. Unclosed tags can cause errors and lead to unexpected behavior. Use a code editor with syntax highlighting to help you identify and fix any missing closing tags.
Important Note
Validate your HTML code using tools like the W3C HTML validator. This will help you ensure that your code is compliant with the latest HTML standard and is free of errors.
Summary
- HTML 5 is the latest version of the HTML standard, used for creating web pages.
- HTML documents are organized into <head> and <body> sections.
- Tags and elements are used to define the structure and content of web pages.
- Attributes provide additional information about HTML elements.
- Comments are ignored by the browser and are used for adding notes to the HTML code.