What is the difference between HTML tags and elements?

后端 未结 8 1095
猫巷女王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:

    Content goes here...
    

    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

    is starting tag of a paragraph and

    is closing tag of the same paragraph but

    This is paragraph

    is a paragraph element.

    Source:tutorialspoint > html_elements

提交回复
热议问题