What are the existing attributes in the html tag?

Asked

Viewed 554 times

2

In HTML5, what are the possible attributes that can be used in element (tag) html? I always learned the attributes by studying by W3schools, but I realized that they say nothing about attributes like prefix and xml:lang and even other simple as alt and disabled, among others that must exist that I do not yet know. Thank you!

  • 2

    disabled in the <html> tag?? What would be the use of this?

  • 1

    Has some attributes common to any element. The element html has only an additional specific attribute - that up to the moment I didn’t even know existed.

  • @Diegof really do not see usefulness, like many other attributes. I am an advocate of the end of attributes without explanation of existence. But if they exist, one day they may appear in some code. I believe you already knew it existed. But, what about when we come across attributes that we have never seen? Whenever I look at a code I see an attribute that we study did not appear.. : ( It is neither by use, but by the will to know that there are... thank you.

  • @bfavaretto but the question is to know only the possible attributes in the element (tag) html and not in all possible elements in HTML5.

  • 2

    I had misunderstood, sorry. In this case it is not wide even. The most reliable answer is in the HTML specification, maintained by W3C (which is unrelated to w3schools, although many people fall for this).

  • I edited my first comment, adding a link to more

Show 1 more comment

1 answer

5


W3C != W3schools

First I would like to mention that it is a very common thing for those who begin to study and ask questions on google, W3schools has no connection with W3C or W3.org, they only use the similar name to say that they teach things contained in W3C, but that doesn’t mean they teach correctly or just HTML/CSS/XML.

W3schools has also been known for the numerous flaws in its examples and tutorials, as well as misinterpreted explanations about some technologies

Today we can say that most of the errors in W3schools have been corrected, but it doesn’t mean that it is official or that it has good examples

About the attributes supported by the tag <html>, it’s not because an attribute is incorrect in a tag that it won’t work, technologies like HTML, JS and CSS work in a similar way in all current browsers, but it doesn’t mean that W3.org implemented them, for example it is not because w3c released HTML5 that it will work equally in all browsers, the W3C is just a kind of "regulator" (who standardizes the technologies) to prevent many differences from arising between browsers which would hinder the development of websites (this has occurred in the past the famous Browser Wars, which goes beyond who is the most used, why one browser wanted to be better than the other creating technologies that were not standards, so it generated a lot of headache).

As I quoted in a comment, you do not need to know the A,B,C of the functioning of something, but seek it in the moment of need. The only utility I see to learn which attributes are all supported by a tag is if you:

  • Will create a Crawler
  • You will create a Javascript library that manipulates the DOM for a very specific purpose

If it’s not quite that, or better if you’re just creating pages to navigate in conventional browsers, then stick to doing the basic and intermediate, if you need something advanced like Opengraph from facebook then you can apply normally, don’t worry big sites like they wouldn’t create a flawed HTML/XML "schema", this would "burn their movie".

There is the use of Microdata or Rdfa which at one time can obstruct HTML if it fails at some point in typing (human error) and for this reason JSON-LD was created, as I mentioned here: What is the "application/Ld+json" type for in a <script tag>? But if you do it carefully and carefully you can still do it without obstructing the code, I mean use something when necessary, there are not many reasons to understand the interface deep down.

The link https://www.w3.org/TR/html-markup/html.html#html html leads east https://www.w3.org/TR/html-markup/global-attributes.html

Core:

accesskey, class, contenteditable, contextmenu, dir, draggable, dropzone, copy, move, link, hidden, id, lang, spellcheck, style, tabindex, title and translate

Events:

onabort, onblur, oncanplay, oncanplaythrough, onchange, onclick, oncontextmenu, ondblclick, ondrag, ondragend, ondragenter, ondragleave, ondragover, ondragstart, ondrop, ondurationchange, onemptied, onended, onerror, onfocus, oninput, oninvalid, onkeydown, onkeypress, onkeyup, onload, onloadeddata, onloadedmetadata, onloadstart, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup, onmousewheel, onpause, onplay, onplaying, onprogress, onratechange, onreadystatechange, onreset, onscroll, onseeked, onseeking, onselect, onshow, onstalled, onsubmit, onsuspend, ontimeupdate, onvolumechange and onwaiting

XML:

xml:lang, xml:space and xml:base

But I must remember, nay is because the attribute oncanplaythrough this listed is that it will work and nay is because the attribute disabled nay this listed that will not work (it is very likely to work), the operation in each browser may occur in a totally different way from other (although today most are working well standardized)but it is not because the browser supports something that this use is valid according to the standardization.

In short pattern is a thing, work is another. However I always prefer to try to follow the pattern to the maximum and on rare occasions make use of some hack (as the common case in CSS) that is not standard to help achieve a goal, often due to lack of some functionality in a given browser.

  • Detail: you did not link to the specification, but to a document with recommendations for using html. Ali seems to have at least one more attribute (contextmenu).

  • @bfavaretto I think I understand, I’ll finish another answer and I’ll come back to edit this =)

  • @bfavaretto I saw your other comment, the specification would be this: https://www.w3.org/TR/html5/dom.html#global-Attributes ?

  • I understand that yes. The problem is that nowadays the specifications are not very stable, they are constantly updated.

  • 1

    @bfavaretto A yes, but I think it was close to what I wanted (tried at least) to say with the answer, it is not because something is listed there that will work, or because it is not listed that will not work. I guess the point I wanted to make was this: You do not need to know the A,B,C of the functioning of something, but seek it in the moment of need. The only utility I see to learn which are all attributes supported by a tag is if you: - Will create a Crawler - ...

  • @bfavaretto ... I removed the "what is supported in the HTML tag" part and left it only as reference. But if you think there’s still something wrong please guide me. Thank you =)

  • 1

    I don’t agree with this point where you want to go (maybe because I like to know things in detail), but the answer is good anyway :)

  • @bfavaretto I also like to know in detail =) but today I am accustomed to measuring the cost of time, taking into account that some things in HTML5 that would be implemented were removed before HTML5 became standard, some browsers have even implemented features that were soon removed from the standard of W3 :/ - And I say, I don’t see much use in knowing the "interfaces" in depth unless you are: Developing a rendering engine, Crawler, or a DOM manipulation tool for something specific =) -- But thanks for the support

  • 1

    I loved the reply from @Guilhermenascimento, he managed to absorb the need of the question well. But in my view that I’m a person who’s starting school, let go of A,B,C.. You can even give speed in learning the most relevant utilities, but at the same time I stop knowing something that may be important ahead and maybe not even know that A,B,C, exist... and the day you need to use something that I never knew before I can end up generating "gambiarras". So, in this part, I agree with the bfavaretto. But William you are a superhero for me.. Thank you very much! :)

  • 2

    @Ingridfarabulini Thank you =) I am happy with your comment. What I mean still with the answer is to stick to the basics and study as you implement something advanced, so I quoted the "then get attached to doing the basic and intermediate". You are also a heroine, because unlike many you prefer to look for the right way even if it is more difficult, congratulations!

  • 1

    @Guilhermenascimento thank you for the words, it is true, I believe that if at least more developers had this interest to do what is right, we would have a technological world "no more boring", but more coherent and less depressing. =)

Show 6 more comments

Browser other questions tagged

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