Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Attribute name not allowed on element div at this point"

I am getting a W3V validator error that I can't understand:

Line 31, Column 61: Attribute name not allowed on element div at this point.

That is this row:

<div name="message" class="jGrowl bottom-right errorGrowl"></div> 

Full HTML:

<!DOCTYPE html> <html>     <head>         <title>jGrowl</title>          <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">         <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>              <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js"></script>          <script type="text/javascript" src="data/awo-jgrowl.js"></script>         <script type="text/javascript" src="data/shortcut.js"></script>          <link rel="stylesheet" type="text/css" href="data/awo-jgrowl.css">          <script type="text/javascript">             $(document).ready(function() {                 $('div[name=message]').awomsg('Input message', {sticky: true});             });              shortcut.add("m",function() {                 $('div[name=message]').awomsg('Input message', {sticky: true});             });              shortcut.add("h",function() {                 alert('ur doin it wrong');             });         </script>      </head>     <body>         <div name="message" class="jGrowl bottom-right errorGrowl"></div>     </body>  </html> 
like image 332
Thew Avatar asked Feb 10 '11 20:02

Thew


People also ask

Can I use name attribute on div?

There is no name attribute for div elements. If you want to uniquely identify one, then use id . If you want to mark one as a member of a group, then use class . The only place you can use a name attribute (that hasn't been deprecated) is on form controls ( input , select , textarea and button ).

Can you add name to div?

If you need to 'name' a div in order to address it from javascript or otherwise uniquely identify it on a page, you can use the id attribute. That said, most modern browsers will handle a name attribute on a div with no issues but it does not conform to HTML standards.


1 Answers

I found some entry from:

Markup Validation Error: "Attribute name not allowed on element at this point" error #HTML5

Just in case you intend to define a custom attribute, you have to prepend the attribute with "data-".

So in this case, name would be: data-name="".

And you can reference it by 'div[data-name="value"]'.

like image 57
Ross Avatar answered Oct 02 '22 23:10

Ross