What is HTML? Every Web developer need to know
![HTML](https://codenestors.com/wp-content/uploads/2023/12/What-is-HTML.png)
introduction
HTML full-form is “Hypertext Markup Language“. HTML is must for creating web pages or complete web applications. in simple word you can’t build website without Hypertext Markup Language
This guide is your go-to resource to learn everything about Hypertext Markup Language(HTML), starting from the basics to more advanced features.
I want to make Hypertext Markup Language easy to understand even if you’ve never coded before. I’ll guide you through building web pages with Hypertext Markup Language step by step in simple terms.
What is HTML ?
Hypertext Markup Language is like a set of instructions for web pages. It uses tags to label content and organize how a page looks. Here’s a simple example of an Hypertext Markup Language document:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<header>
<h1>Welcome to My Web Page</h1>
</header>
<nav>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
<section>
<h2>About Me</h2>
<p>This is a brief introduction about myself.</p>
</section>
<section>
<h2>Contact Information</h2>
<p>Email me at: <a href="mailto:your@email.com">your@email.com</a></p>
</section>
<footer>
<p> 2023 My Web Page. All rights reserved.</p>
</footer>
</body>
</html>
![use of html](http://codenestors.com/wp-content/uploads/2023/12/what-is-html.jpg)
What is Hypertext Markup Language(HTML) Document Structure ?
- `<!DOCTYPE html >` – This is Doc type declaration .Declares the Hypertext Markup Language version (current HTML5).
- `<html>` – This is root element is wraps the entire document.
- `<head>` – This Contain meta data about page , such as title and styles and characterset.
- `<meta charset=”UTF-8″>` – Defines the character set for the document (UTF-8 supports a wide range of characters).
- `<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>` – Sets the viewport properties for responsive design.
- `<title>` – This sets title of webpage (You can see this in the browser tab)
- `<body>` – Contains the content of the HTML document. ( What User Is See )
- `<header> `
,
`<nav>`,
`<section>`,`<footer> ` – semantic html tags to structure different parts of the webpage. - `<h1>` to `<h6>` – Heading tags for defining headings. The number indicates the level of importance.
- `<p>` – Paragraph tag for defining text paragraphs.
- `<ul>`,`<li>` – Tags for creating an unordered list and list items.
- `<a href=”” >` – Anchor tag for creating hyperlinks. The href attribute specifies the link destination.
- `<footer>` – Represents the footer of a page, usually containing copyright information.
HTML elements and tags
Hypertext Markup Language relies on a combination of elements and tags to structure and present content on the web. Let’s explore the concepts of Hypertext Markup Language elements and tags:
An HTML element is a fundamental building block that defines the structure and content of a web page. Each element consists of a start tag, content and end tag. Elements can also be self-closing.
<p>This is a paragraph element</p>
in this example
- `<p>` is starting tag
- `This is a paragraph element` is content
- `</p>` is ending tag
HTML tags are markers that define the beginning and end of an Hypertext Markup Language element. Tags are used to enclose and structure content, providing instructions to the browser on how to display the information.
HTML Attributes
HTML attributes provide additional information about HTML elements and help define their behavior, appearance, or properties. Attributes are always included within the opening tag of an Hypertext Markup Language element and are typically written as name/value pairs.
<a href="https://www.example.com">Example</a>
In above example “href” attribute is provides the link destination for the anchor tag
<p class="highlight">This is a highlighted paragraph</p>
in this last example “class” attributes is Used for styling elements with CSS
Like this their is more attributes in Hypertext Markup Language .some attributes is used with specified tags .you can explore more on W3School or MDN.
let’s explore some common used HTML tags list
paragraph
The Hypertext Markup Language `<p>` tag is like a text box on a webpage. When you want to create a paragraph you use ` <p>` at the beginning and `</p>` at the end. you can see in below exmple :
<p>This is a sample paragraph of text.</p>
Here’s a cool thing the computer or browser automatically puts some space before and after your paragraph. It’s like adding a little margin to make paragraphs look nice and separate from each other on the webpage. So your text doesn’t feel crowded and everything appears more organized
heading
Hypertext Markup Language heading tags from `<h1>` to `<h6>` serve the purpose of defining hierarchical headings on a webpage. Each tag represents a different level of importance with `<h1>` being the most significant and `<h6>` the least. These tags not only structure content for better readability but also play a crucial role in search engine optimization where search engines use heading tags to understand the hierarchy and relevance of content.
<h1>Main Heading</h1>
<h2>Subheading</h2>
In this example `<h1>` signifies the main heading, while `<h2>` represents a subheading. Proper use of heading tags contributes to a well-organized and accessible webpage.
link
The Hypertext Markup Language `<a>` tag commonly referred to as the anchor tag is utilized for creating hyperlinks on a webpage. It allows users to navigate to another web page a specific section within the same page or external resources like documents or images. The href attribute within the `<a>` tag specifies the destination URL.
<a href="https://codenestors.com">Visit codenestors</a>
By click on “Visit codenestors” would redirect user to website specified in the href attribute. The `<a>` tag also known as the anchor HTML tag is fundamental for connecting and navigating between different parts of the web.
image
The `<img>` tag also known as the HTML image tag is used to embed images in a webpage. It allows the inclusion of visual content enhancing the overall presentation of the site. The src attribute within the `<img/>` tag specifies the image file source (URL or file path) and the alt attribute provides alternative text for accessibility.
<img src="image.jpg" alt="Description">
In this example the `<img>` tag displays an image named “image.jpg,” and the “Description” within the alt attribute describes the image content. The image tag is essential for incorporating graphics and visuals into documents.
form
The ` <form>`tag is used to create interactive forms on a webpage allowing users to input data that can be submitted to a server for processing. The `<form>` tag wraps various form elements such as text fields, checkboxes and buttons. The action attribute specifies the URL where the form data is sent and the method attribute defines how data is transmitted (GET or POST).
<form action="/submit" method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<input type="submit" value="Submit">
</form>
- Two pairs of `<label>` and `<input>` are used. The “for” attribute in the `<label>` tag associates it with the corresponding `<input>` using the id attribute.
- The first pair is for a username input and the second pair is for a password input.
- The type attribute in the `<input>` tag specifies the input type (text for the username and password for the password).
- The id and name attributes provide identifiers for the input fields.
- The required attribute ensures that users must fill in these fields before submitting the form.
- The`<input type=”submit” >` creates a submit button.
table
The `<table>` tag is a fundamental element for structuring and presenting tabular data on a webpage. Tables are a versatile tool for organizing information into rows and columns providing a clear and structured layout. The table structure typically involves the use of nested elements including `<tr>` for rows and `<th>` for header cells and `<td>` for data cells.
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</table>
the `<table>` tag encapsulates the table, `<tr>` defines rows, `<th>` creates header cells and `<td>` represents data cells. The headers provide context to the information in each column enhancing the overall readability of the table. HTML tables are used for organizing data presenting it in a visually manner and supporting a structured display of information on websites.
list
Hypertext Markup Language provides versatile options for creating lists on webpages enhancing the presentation and organization of content. There are two main types of lists: ordered lists `<ol>` and unordered lists`<ul>` both of which use the `<li>` list item tag.
Ordered List
<ol>
<li>Item 1</li>
<li>Item 2</li>
</ol>
The `<ol>` tag is used to create an ordered list where each `<li>` represents a list item. The list items are automatically numbered providing a structured sequence.
Unordered List
<ul>
<li>Item A</li>
<li>Item B</li>
</ul>
The `<ul>` tag generates an unordered list typically displayed with bullet points. Each `<li>` tag signifies an individual list item.
Lists in Hypertext Markup Language are like well-organized containers for information on a webpage. They help make things look neat and easy to understand. Whether it’s showing steps in a recipe, items on a menu, or important points in an article HTML lists make the webpage look clean and friendly.
Div and Span
The `<div>` and `<span>` tags are essential for structuring and styling content on a webpage.
`<div>` (Division)
<div>This is a division</div>
The `<div>` tag defines a division or section in document. It’s like a container that helps organize and group content for styling or layout purposes.
`<span>` (Inline Division)
<span>This is an inline division</span>
The `<span>` tag is similar to `<div>` but it used for inline elements. Its handy when you want to apply styles or manipulate specific parts of text without affecting the entire block.
In simpler words `<div>` is like big box that holds content together and `<span>` is like small box that you can put around single word or small part of text for styling. Both play a role in making sure the webpage looks good and is organized.
let’s discuss some more other features
HTML Comments
comments are used to include notes or annotations within the code that are not visible when the page is rendered in a browser. They are created with the closing tag.
<!-- This is an HTML comment -->
comments are like little notes that developers write in the code to remind themselves or explain things. It’s like leaving helpful messages for the person working on the code so they understand what’s going on. These comments don’t show up on the actual webpage. they’re just there to make it easier for the developers. Its like writing reminders on sticky notes for yourself when you’re working on a project.
HTML semantic tags
semantic tags are special elements that carry meaning about the structure and content of a webpage. Unlike generic tags these semantic tags provide context to both browsers and developers making the code more descriptive and improving accessibility.
- `<header>` : Represents the header of a section.
- `<nav>` : Defines a navigation bar.
- `<article>` : Represents an independent piece of content.
- `<section>` : Defines a section in a document.
- `<aside>` : Represents content aside from the main content.
- `<footer>` : Represents the footer of a section or page.
Semantic tags help organize and clarify the purpose of different parts of a webpage making it more readable for developers and assisting browsers in better understanding the structure for improved accessibility and SEO.
HTML Entities
HTML entities are special codes used to represent reserved characters and symbols in Hypertext Markup Language documents. These codes start with an ampersand (&) and end with a semicolon (;). They are used to display characters that have a specific meaning in HTML, such as reserved characters like `<` and `>` or special symbols like ©
and —
.
< represents <
> represents >
© represents ©
entities ensure that browsers correctly interpret and display characters without conflicting with the code structure. They are specially crucial when working with characters that have a reserved meaning in Hypertext Markup Language preventing confusion and rendering issues.
Difference between HTML and XHTML
Hypertext Markup Language and XHTML (Extensible Hypertext Markup Language) are two web markup languages with key distinctions. Hypertext Markup Language has a forgiving syntax allowing more flexibility while XHTML follows stricter XML rules. HTML is lenient in parsing and allows optional document structures whereas XHTML demands well-formed documents with a rigid structure. In HTML(Hypertext Markup Language) certain tags can be self-closing but in XHTML all tags must be explicitly closed. HTML documents may or may not include a DOCTYPE declaration while XHTML requires it for proper rendering. HTML uses the text/html
MIME type while XHTML uses application/xhtml+xml
. HTML5 combining features of both is the prevalent standard in modern web development.
HTML style and colors
Styling Hypertext Markup Language content enhances its visual presentation. Here are some ways to apply styles
- Inline style
Apply styles directly to an element using the style attribute.
Example: `<h1 style=”blue;” > Heading</h1>` - Internal CSS
Define styles within the `<style>` element in the head of the HTML document. - External Stylesheet
Create a separate CSS file (e.g., styles.css) with rules and link it to the Hypertext Markup Language document.
Example `< link rel=”stylesheet” href=”style.css” >`
Here are some references of Hypertext Markup Language style and css MDN CSS References, W3Schools CSS Reference and you can find another references on Google
adding javascript to hTML
When you add JavaScript to your Hypertext Markup Language it helps make your website more interesting and interactive. JavaScript is like a helper language that works in your web browser. It can change how things look on your webpage and do cool stuff when people click on things.
Inline Javascript
Put your JavaScript code directly inside your HTML file using `<script>` tags.
<!DOCTYPE html>
<html>
<head>
<title>My Web Page</title>
<script>
// Your code goes here
function greet() {
alert("Hello, World!");
}
</script>
</head>
<body>
<h1>Welcome to my web page</h1>
<button onclick="greet()">Click me</button>
</body>
</html>
External Javascript
- If your code is big, it’s better to keep it in a separate file
- Link your HTML to the external JavaScript file using `<script>` tag.
<!DOCTYPE html>
<html>
<head>
<title>My Web Page</title>
<script src="script.js"></script>
</head>
<body>
<h1>Welcome to my web page</h1>
<button onclick="greet()">Click me</button>
</body>
</html>
// Your code goes here
function greet() {
alert("Hello, World!");
}
Remember JavaScript makes your webpage dynamic and responsive to user actions. Whether you’re adding it directly in your Hypertext Markup Language or linking to an external file it’s a powerful tool to make your website more engaging
What is HTML(Hypertext Markup Language) and why is it essential for creating web pages?
HTML stands for “Hypertext Markup Language.” It is a fundamental language for creating web pages and web applications. Hypertext Markup Language uses tags to structure content and organize the appearance of a page. Without HTML you cannot build a website.
What are HTML elements and tags?
HTML elements are building blocks that define the structure and content of a web page. Each element has a start tag, content and end tag. Tags on the other hand mark the beginning and end of Hypertext Markup Language element enclosing and structuring content to instruct the browser on how to display information.
Can you explain the purpose of HTML entities?
HTML entities are special codes used to represent reserved characters and symbols in Hypertext Markup Language documents. They start with an ampersand (&) and end with a semicolon (;). HTML entities are crucial for displaying characters that have a specific meaning in HTML without conflicting with the code structure.