Detailed explanation of the difference between tags and elements in HTML

Detailed explanation of the difference between tags and elements in HTML
I believe that many friends who are new to web pages are like me, and don’t understand how elements, tags, and attributes are defined in HTML, and what is the difference between elements and tags. In order to understand it thoroughly, I searched and consulted some information. Now I write down my conclusions and share them with netizens who have the same confusion as me:

Many people may not have a clear idea of ​​which is a tag and which is an element, including me before, I have always been confused.
In fact, the concept between the two is still very clear:
For example, <p> is a tag;
<p>Content goes here</p> This is an element, which means that an element consists of a start tag and an end tag, and is used to contain certain content;
There is one notable exception here, which is that <br/> itself is both a start tag and an end tag, but it contains no content, so it is just a tag.

1. Elements :

An HTML web page is actually a text file composed of many different HTML elements, and any web browser can run HTML files directly. So it can be said that HTML elements are the basic objects that constitute HTML files, and HTML elements can be said to be just a general term. HTML elements are defined using HTML tags.

2. Tags :

Tags are objects enclosed in angle brackets “<” and ">”, such as <head>, <body>, <table>, etc. Most tags appear in pairs, such as <table></talbe>, <form></form>. Of course, there are a few that do not appear in pairs, such as <br>, <hr>, etc.

Tags are used to mark HTML elements. The text between the start and end tags is the content of the HTML element.

3. Attributes :

HTML attributes provide various additional information for HTML elements. They always appear in the form of name-value pairs such as "attribute name = attribute value", and attributes are always defined in the start tag of HTML elements.

Example :

<html> <head> <title>Example title</title> </head> <body bgcolor="red"> <p>This is an example page</p> </body> </html> In this example, <p>This is an example page</p> is the HTML element, and “This is an example page” is the specific content of the element. <head><title><body> etc. are HTML tags, which constitute HTML elements. The bgcolor="red" in <body bgcolor="red"> is the attribute of the tag, which defines how the tag should be configured. In short, you don’t have to worry too much about the difference between elements and tags. In actual work, we just refer to them as tags. Attributes are easy to understand. They are parameters that add various additional information or configuration options to HTML tags.

<<:  This article will help you get started and understand the basic operations of Jquery

>>:  Summary of three ways to implement ranking in MySQL without using order by

Recommend

20 Signposts on the Road to Becoming an Excellent UI (User Interface) Designer

Introduction: Interface designer Joshua Porter pub...

How to create a virtual environment using virtualenv under Windows (two ways)

Operating system: windowns10_x64 Python version: ...

Based on JavaScript ES new features let and const keywords

Table of contents 1. let keyword 1.1 Basic Usage ...

MySQL 5.6.33 installation and configuration tutorial under Linux

This tutorial shares the installation and configu...

Detailed explanation of the workbench example in mysql

MySQL Workbench - Modeling and design tool 1. Mod...

Detailed explanation of Alibaba Cloud security rule configuration

Two days ago, I took advantage of the Double 11 s...

Take you to understand MySQL character set settings in 5 minutes

Table of contents 1. Content Overview 2. Concepts...

vue-cropper component realizes image cutting and uploading

This article shares the specific code of the vue-...

Solve the problem of using less in Vue

1. Install less dependency: npm install less less...

Detailed explanation of Angular data binding and its implementation

Table of contents Preface What is data binding? T...

How to call the interrupted system in Linux

Preface Slow system calls refer to system calls t...

Summary of Operator Operations That Are Very Error-Prone in JavaScript

Table of contents Arithmetic operators Abnormal s...

How to use Docker Compose to implement nginx load balancing

Implement Nginx load balancing based on Docker ne...

How to view files in Docker image

How to view files in a docker image 1. If it is a...

Summary of the understanding of virtual DOM in Vue

It is essentially a common js object used to desc...