What are HTML interfaces for?

Asked

Viewed 64 times

3

Every specification (documentation) that I see of a certain HTML element, always specify the element to a type of interface as, for example:

  • HTMLTableCaptionElement
  • HTMLButtonElement
  • HTMLBRElement
  • HTMLElement

These interfaces of the elements refer to what? And what are they for?

  • 1

    I think this should interest you tb https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Categorias_de_contents

1 answer

4


Interface in this context indicates that it is a contract.

You know what it is API? Application Programming Interface. It’s the same thing as the term in that context. It’s what defines how you should use something. It is what allows contact of your code with the internal code of a technology that is available to you.

Let’s translate one of these texts:

The HTMLElement interface represents any HTML element

Would be:

The mechanism of communication with the browser called HTMLElement represents any HTML element.

Better use the term that already indicates all this in a word.

Each one of them is for something a little different and has to read the documentation of each, I think the question is not about that, because if it were wide.

  • The documentation is very extensive. He can start by studying https://dom.spec.whatwg.org/#htmlcollection and unlocking the links that appear. Wanting to understand what an interface is in the context of HTML is not so easy.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.