captainsac
captainsac

Reputation: 2490

Validation (HTML 4.01): Element 'style' cannot be nested within element 'div'

I am using ASP.NET 4.0 and I am writing an internal css in an aspx file. The style block is the first block in a ContentPlaceHolder. The style block is giving an error message

Validation (HTML 4.01): Element 'style' cannot be nested within element 'div'

Screenshot:

enter image description here

ContentPlaceHolder is in a div in Master page as follows

<div id="column2">
    <asp:ContentPlaceHolder ID="Content" runat="server">
    </asp:ContentPlaceHolder>
</div>

What may be the problem?

Thank you

Upvotes: 0

Views: 3863

Answers (1)

walther
walther

Reputation: 13600

It's written in English. Element style can't be nested within a div element.
I'd say the best way to do this is to use a placeholder for styles in <head> and insert styles there. However, if possible, I'd try to avoid such style blocks in html altogether.

And one more detail. You may be wondering why it says you can't nest it in div, when you have it in <asp:content .. element. Even though that's true, it's just a placeholder and it would end up within <div id="column2">.

Upvotes: 2

Related Questions