What is the difference between HTML tags and elements?

后端 未结 8 1069
猫巷女王i
猫巷女王i 2020-12-07 13:24

I notice that most people use the words HTML tags and HTML elements interchangeably.

But what is the difference between them?

The way I s

相关标签:
8条回答
  • 2020-12-07 13:59

    HTML Elements

    An HTML element usually consists of a start tag and end tag, with the content inserted in between:

    <tagname>Content goes here...</tagname>
    

    The HTML element is everything from the start tag to the end tag. Source

    HTML Attributes

    An attribute is used to define the characteristics of an HTML element and is placed inside the element's opening tag. All attributes are made up of two parts: a name and a value.

    • All HTML elements can have attributes
    • Attributes provide additional information about an element
    • Attributes are always specified in the start tag
    • Attributes usually come in name/value pairs like: name="value" Source

    HTML Tag vs Element

    "Elements" and "tags" are terms that are widely confused. HTML documents contain tags, but do not contain the elements. The elements are only generated after the parsing step, from these tags. Source: wikipedia > HTML_element

    An HTML element is defined by a starting tag. If the element contains other content, it ends with a closing tag.

    For example <p> is starting tag of a paragraph and </p> is closing tag of the same paragraph but <p>This is paragraph</p> is a paragraph element.

    Source:tutorialspoint > html_elements

    0 讨论(0)
  • 2020-12-07 14:00

    http://html.net/tutorials/html/lesson3.php

    Tags are labels you use to mark up the begining and end of an element.

    All tags have the same format: they begin with a less-than sign "<" and end with a greater-than sign ">".

    Generally speaking, there are two kinds of tags - opening tags: <html> and closing tags: </html>. The only difference between an opening tag and a closing tag is the forward slash "/". You label content by putting it between an opening tag and a closing tag.

    HTML is all about elements. To learn HTML is to learn and use different tags.

    For example:

    <h1></h1>
    

    Where as elements are something that consists of start tag and end tag as shown:

    <h1>Heading</h1>
    
    0 讨论(0)
提交回复
热议问题