3

This one is strange...I have the following markup for a view using Razor view engine ASP.Net MVC 3 RC

            <p>
                <div class="editor-label">
                    @Html.LabelFor(model => model.Client.FirstName)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.Client.FirstName) @Html.ValidationMessageFor(model => model.Client.FirstName)
                </div>
                <div class="editor-label">
                    @Html.LabelFor(model => model.Client.LastName)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.Client.LastName) @Html.ValidationMessageFor(model => model.Client.LastName)
                </div>
            </p>

The problem is that when it renders, the P tag is not surrounding the DIVs! It renders like this:

<p>
                </p><div class="editor-label">
                    <label for="Client.FirstName">First Name</label>
                </div>
                <div class="editor-field">
                    <input class="text-box single-line" data-val="true" data-val-required="The First Name field is required." id="Client_FirstName" name="Client.FirstName" value="My FName" type="text"> <span class="field-validation-valid" data-valmsg-for="Client.FirstName" data-valmsg-replace="true"></span>
                </div>
                <div class="editor-label">
                    <label for="Client.LastName">Last Name</label>
                </div>
                <div class="editor-field">
                    <input class="text-box single-line" data-val="true" data-val-required="The Last Name field is required." id="Client_LastName" name="Client.LastName" value="My LName" type="text"> <span class="field-validation-valid" data-valmsg-for="Client.LastName" data-valmsg-replace="true"></span>
                </div>

What the heck is going on? Any help is appreciated!

1
  • Do you have link where this happens? I just threw the same code (allthough with a different form) on a page of mine and it works just fine. Commented Dec 6, 2010 at 5:46

3 Answers 3

4

a paragraph cannot contain other block level elements. w3c

also check out this question

Sign up to request clarification or add additional context in comments.

Comments

2

Hmmm, it seems like it is just standard browser behavior?

http://blog.programmingsolution.net/html/html-div-tag-inside-html-p-paragraph-tag-does-not-work-correctly/

Comments

2

The P element represents a paragraph. It cannot contain block-level elements e.g. DIV

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.