Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8508401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:09:04+00:00 2026-06-11T03:09:04+00:00

I am having a problem where I try to render a <table> inside of

  • 0

I am having a problem where I try to render a <table> inside of parent container, but MVC3 Razor always renders the outside of the container tag. This causes problems when trying to control the outside parent container via Javascript.

Razor Example:

<span id="mySpan">
 @Html.Action("Table1", "GetMyTable")
</span>

HTML that is output:

 <span id="mySpan"></span>  
 <table>
  <thead><tr><th>Header</th></tr></thead>
  <tbody>
   <tr><td>Foo</td></tr>
   <tr><td>Bar</td></tr>
  </tbody>
 </table>

No matter which parent container I try to stick the table into, a div, span, p, the table always renders OUTSIDE the container’s tags! Can anyone explain what I am doing wrong? How should I code the Razor syntax to properly add the table inside those tags?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T03:09:06+00:00Added an answer on June 11, 2026 at 3:09 am

    as you are viewing the output in Firebug, what is happening is you are seeing an “effective” view of the html, after the browser engine has parsed it.
    in HTML5, many tags do not need to be explicitly closed. If you include a tag “inside” another that is invalid (like a table inside a span), the browser assumes what you are doing is using an unclosed span tag, so it automatically closes it for you before starting the table tag.

    The easiest fix here would be either not to “wrap” the table, or wrap it with something that HTML5 considers valid, such as a section tag.

    Another option would be going back to XHTML1.1, where a table is valid inside a div (but not inside a span). Also, XHTML requires explicit closing tags, so this behavior would not show up there. (the same thing for XHTML5, though it’s still invalid to wrap a table with a div in XHTML5)

    Viewing the raw source would reveal that Razor is not axtually changing anything here; it is the browser. It is good to see this, though; so you know what the browser is expecting and how it’s handling what you are sending it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am having this problem try to use the cocos2d CCScrollLayer I have added
I'm having a problem with TRY...CATCH blocks. Can someone explain why the following code
I am having problem with qtip content button. When i try to change a
I'm working with the Entity Framework and I'm having a problem: When I try
So I searched and couldn't find anyone else having this problem: When I try
I'm having a problem writing to a file: FileInputStream fin; try { fin =
I'm having a strange problem with unit test in grails, when I try to
I'm having a slight problem with my SDL/Opengl code, specifically, when i try to
I'm having a really difficult time debugging this problem. Whenever I try to establish
I am using the jQuery UI components but having some problems. If I try

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.