Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What Is the Difference Between a Tag and an Element?

In some texts about XML, the terms tag and element seem to be used interchangeably. Do they mean the same thing, or are do these terms represent different things?

like image 376
Sujit Avatar asked Aug 19 '12 15:08

Sujit


People also ask

What is the difference between an element and a tag in XML?

Tags mark the start and end of an element. See the specification: Each XML document contains one or more elements, the boundaries of which are either delimited by start-tags and end-tags, or, for empty elements, by an empty-element tag.

What is a tag or element in HTML?

Definition and Usage. The <a> tag defines a hyperlink, which is used to link from one page to another. The most important attribute of the <a> element is the href attribute, which indicates the link's destination. By default, links will appear as follows in all browsers: An unvisited link is underlined and blue.


2 Answers

Tags mark the start and end of an element.

  • <foo> — start tag
  • </foo> — end tag
  • <foo></foo> — element

See the specification:

Each XML document contains one or more elements, the boundaries of which are either delimited by start-tags and end-tags, or, for empty elements, by an empty-element tag.


See also section 5 of NOT the comp.text.sgml FAQ

like image 159
Quentin Avatar answered Oct 06 '22 00:10

Quentin


<address category = "residence">     <name>name content</name>     <company>company content</company>     <phone>(011) 123-4567</phone> </address> 

Here <address> is an element which has attribute category

Start and end tags of an element must be identical.

like image 25
Tandilashvili Avatar answered Oct 06 '22 01:10

Tandilashvili