Words reserved in HTML?


The doubt came to me when I saw a form like this:

<form method="post">
    <input type="text" name="name"   placeholder="Your name*">
    <input type="text" name="number" placeholder="Your phone number*">
    <button type="submit" value="Submit">Submit</button>

Does giving an input the name name , or number be problematic in some scenario?

When I saw it I thought it might be reserved words, but I was looking for a list of reserved words in HTML and I did not find anything.

asked by A. Cedano 27.07.2017 в 18:29

3 answers


Short answer

In the case of values, there are no words reserved for HTML but there could be words for other elements that are used together with HTML. Likewise, considering that each "engine" interprets HTML in a particular way, Internet Explorer comes to mind, it could have non-standard restrictions.


In "pure HTML" there are no reserved words because there are no custom labels or attributes but when using XML it is possible to have custom labels and attributes. It is in this case, and in the use of other "technologies" in which there could be reserved words, such as the use of DOM, APIs such as Geolocation, libraries and frameworks such as jQuery, etc.

The case that motivated the question, it should be noted that the values of the attributes are in quotation marks, but the use of quotation marks is not mandatory. It should be noted that the attributes have a specified data type and each type has rules about the valid values. Details about the data types in HTML version 4 in link .

In the specific case of the attribute name of the element input the data type is CDATA which does not include keywords.

Another thing is the guidelines that are established in style guides. While each programmer has free will, when thinking of carrying out the work of web development in a professional manner it is very useful to adopt a style guide. One of the premises is that the code is clear and this implies, whenever it is possible to avoid the use of names of labels, attributes, methods, etc. as values names, or to apply some conventions such as the use of uppercase and lowercase letters with a certain pattern that is not usual when writing in natural language such as using only lowercase letters or certain combinations such as "camel case".

It should be noted that in the case of HTML5 if there are personalized labels for data management. They have the prefix data- .



answered by 27.07.2017 / 18:41

In html there is no problem with "reserved words", when defining property values, so as in this case it is the same:

<input type="text" name="name"   placeholder="Your name*">


<input type="text" name="nombre"   placeholder="Your name*">

but for good practice it is suggested not to name the values of the properties as the attributes.

This question came to my mind, in this case the value influences since the bgcolor property defines a color:

Why does HTML accept as an arbitrary string color?

answered by 27.07.2017 в 18:46

There are no words reserved in HTML, however it is not advisable to create a class with the name "class". The idea is that when you have to debug your code it will be intuitive and understandable for you. I suggest that instead of putting name place id_name so it will be easier.

answered by 27.07.2017 в 18:39