1

Traditionally, I would use a div for this but I thought I would ask to see if there was a more appropriate element.

I have a table that has a fully realized thead but the tbody is empty. Following the table I have a script element (of type text/javascript) that has the elements to put into the table and I'm using jsrender to create the elements within the tbody from the elements in the javascript.

From what I can tell, it is improper to have the script element inside the table except possibly inside one of the td or th elements but that sounds kinda gross to me.

I could just have the script tag come after the table with no container around it and find it via next sibling of the table but that seems fragile to me. I'd prefer to have a container. As I mentioned, a div would work but thought there may be something in html5 to specifically address this type of concept.

pedz
  • 2,271
  • 1
  • 17
  • 20
  • [This answer](http://stackoverflow.com/questions/2741441/giving-the-script-tag-an-id) might be of use to you. The point being that you could give them IDs. There's no real problem to having them outside a container. – Joseph Marikle Dec 31 '12 at 21:52
  • I tend to over design -- which is really bad. But if I have more than one of these pairs on a page, I could not use id. I actually used id and then started to have some heartburn. I could have various attributes that hook the two together but a simple container seemed easiest. I think I'll just go with a div. Thank you for this command and the other comment on the other answer. – pedz Dec 31 '12 at 23:32

3 Answers3

1

The container for scripts is <script>. Anything additional contain is fine, but not really adding any semantic value to the page.

DA.
  • 39,848
  • 49
  • 150
  • 213
  • I might not have made my question clear. I'm looking for a container for a table element and a script element. – pedz Dec 31 '12 at 23:29
0

Yes, if you need a container, use the div element. It "has no special meaning at all", so the following two snippets are semantically the same:

<table><!-- … --></table>
<script></script>

<div>
  <table><!-- … --></table>
  <script></script>
</div>
unor
  • 92,415
  • 26
  • 211
  • 360
-1

<section></section> is what I would use for this particular case. But it's a matter of semantics/personal preference. You're not gaining much by using the new tag here.

Christopher Marshall
  • 10,678
  • 10
  • 55
  • 94
  • This is not really the purpose of `section`. `section` is more related to database record structure. Bruce Lawson at [html5doctor.com](http://html5doctor.com/the-section-element/) gives the full breakdown. – Joseph Marikle Dec 31 '12 at 21:50