. In the same way, we can give it+4 javascript html...">

Can we name html <table>?

For <form> we can name <form name="name"> .

In the same way, we can give it <table name="table1">

+4
source share
5 answers

name not a valid <table> attribute in HTML5. From the thin specification :

Allowed Attributes

global attributes and boundaries

And if you look at global attributes , you will not find name in the list.

Therefore, you cannot put the name attribute in <table> and still have valid HTML. id , however, is a global attribute, so you can use it instead of name (unless, of course, your name is unique on the page).

Try the following:

 <!DOCTYPE html> <head><title>t</title></head> <body> <table name="pancakes"></table> </body> 

through http://validator.w3.org , and you will see that he does not like the name on <table> .

If you are still writing HTML4, you still cannot put the name attribute on the <table> . From the thin specification :

 <!ATTLIST TABLE -- table element -- %attrs; -- %coreattrs, %i18n, %events -- summary %Text; #IMPLIED -- purpose/structure for speech output-- width %Length; #IMPLIED -- table width -- border %Pixels; #IMPLIED -- controls frame width around table -- frame %TFrame; #IMPLIED -- which parts of frame to render -- rules %TRules; #IMPLIED -- rulings between rows and cols -- cellspacing %Length; #IMPLIED -- spacing between cells -- cellpadding %Length; #IMPLIED -- spacing within cells -- > 

There is no name in this list and no name in coreattrs , i18n or events .

+7
source

the name is not allowed for the table, instead you can declare it in the html5 trend

 <table data-name="my_table"></table> 

and use it in jquery, for example:

 $('table [data-name=my_table]'); 
+2
source

No dude, you cannot assign a name to a table element.

For a table, you can specify an identifier or attribute of a class that refers to a specific table in your HTML code, and then based on this, you can make changes to the table through CSS, javascript, jquery, etc.

Hope this information helps ...!

0
source

name is a standard attribute; it can be placed on any element.

However, note that accessing elements using name deprecated in favor of things like id and class . name should be reserved for form elements such as <input> .

-1
source

Yes, you can. eg.

 <table name="test" id="test"> <tr> <td>..Your stuff..</td> </tr> </table> 
-3
source

All Articles