+ 6

What is the difference (or connection) between "tag" and "element" in HTML?

While this two terms are usually used interchangeably, I don't think they are really the same thing. What is your view / understanding...? #want-to-know! ^-^

19th Jun 2017, 5:57 AM
Femyk
Femyk - avatar
5 Réponses
+ 14
Tag - Your Name Element - Yourself
19th Jun 2017, 6:27 AM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 3
HTML tag is the opening and closing entity. For example: <h1></h1> Where as elements are something that consists of start tag and end tag, as shown below: <h1>Heading</h1> For more information, please read here: https://stackoverflow.com/a/8937454
19th Jun 2017, 6:02 AM
Jamie Isaksen
Jamie Isaksen - avatar
+ 3
@Krishna, do you mean the element is the "whole thing" (content + tag) while the tag is the "semantic interface" of the content...? ^-^
19th Jun 2017, 6:40 AM
Femyk
Femyk - avatar
+ 2
An element is an object, a tag is a class of object. In javascript the difference becomes very clear: getElementsByTagName("div") <--- that expression retrieves all the *elements* that are of a certain kind. tag: human elements: ^-^ Famyk ^-^ John Waters .... Get it? Elements are individuals, tags are a reference of a group/kind that may or not contain any individuals.
19th Jun 2017, 10:15 AM
John Waters
John Waters - avatar
+ 2
"do you mean the element is the "whole thing" (content + tag) while the tag is the "semantic interface" of the content...?" Yes. Opening tag: <div> Closing tag: </div> Element: <div>hello [may include child elements]</div>
19th Jun 2017, 10:20 AM
John Waters
John Waters - avatar