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

Detailed explanation of Redis master-slave replication practice using Docker

Table of contents 1. Background 2. Operation step...

Examples of new selectors in CSS3

Structural (position) pseudo-class selector (CSS3...

Detailed explanation of the use of shared memory in nginx

In the nginx process model, tasks such as traffic...

How to deploy k8s in docker

K8s k8s is a cluster. There are multiple Namespac...

Navicat for MySQL 15 Registration and Activation Detailed Tutorial

1. Download Navicat for MySQL 15 https://www.navi...

Let’s talk in detail about how browsers view closures

Table of contents Preface Introduction to Closure...

HTML table tag tutorial (31): cell width and height attributes WIDTH, HEIGHT

By default, the width and height of the cell are ...

Introduction to Spark and comparison with Hadoop

Table of contents 1. Spark vs. Hadoop 1.1 Disadva...

Solutions to VMware workstation virtual machine compatibility issues

How to solve VMware workstation virtual machine c...

Explanation of Truncate Table usage

TRUNCATE TABLE Deletes all rows in a table withou...

Users need to know why

When I was in the securities company, because the ...

CocosCreator Universal Framework Design Network

Table of contents Preface Using websocket Constru...

MySql Sql optimization tips sharing

One day I found that the execution speed of a SQL...

Docker images export and import operations

What if the basic images have been configured bef...