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>
</form>
Giving an input the name name
, or number
could it be problematic in some scenario?
Looking at it I thought it might be reserved words, but I was looking for a list of reserved words in HTML and found nothing.
Short answer
For values, there are no HTML reserved words but there might be for other elements that are used in conjunction with HTML. Also, considering that each "engine" interprets HTML in a particular way, Internet Explorer comes to mind, it could have non-standard restrictions.
Explanation
In "pure HTML" there are no reserved words as there are no custom tags or attributes but using XML it is possible to have custom tags and attributes. It is in this case, and in the use of other "technologies" that there could be reserved words, such as the use of DOM, APIs such as Geolocation, libraries and frameworks such as jQuery, etc.
In the case that prompted the question, it should be noted that attribute values are enclosed in quotes, but the use of quotes is not required. Note that attributes have a specified data type, and each type has rules about valid values. Details about data types in HTML version 4 at https://www.w3.org/TR/html4/types.html .
name
In the specific case of the element attributeinput
, the data type is CDATA , which does not include keywords.Another thing is the guidelines established in style guides. Although each programmer has free will, when thinking about carrying out web development professionally it is very useful to adopt a style guide. One of the premises is that the code is clear and this implies, whenever possible, avoiding the use of names of labels, attributes, methods, etc. as value names, or applying 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 the "camel case".
It should be noted that in the case of HTML5 there are custom tags for data handling. They have the prefix
data-
.References
Related
In html there is no problem with "reserved words", when defining property values, so as in this case it is the same:
that
but for good practice it is suggested not to name property values as attributes.
This question came to mind, in this case the value influences since the bgcolor property defines a color:
Why does HTML accept an arbitrary string as color?
There are no reserved words in HTML, however it is not recommended to create a class with the name "class". The idea is that when you have to debug your code it is intuitive and understandable for you. I suggest that instead of putting name you put id_name so it will be easier.