0

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

captainsac
  • 2,484
  • 3
  • 27
  • 48
  • Usually every content page has two `` and one of them is with `id="head"` and you can use that one to put your ` – Tasos K. May 25 '15 at 10:58
  • 1
    Better you go through this http://stackoverflow.com/questions/2830296/using-style-tags-in-the-body-with-other-html and this http://programmers.stackexchange.com/questions/224422/will-it-be-a-wrong-idea-to-have-style-in-body thread. – Ravimallya May 25 '15 at 11:14

1 Answers1

2

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">.

walther
  • 13,466
  • 5
  • 41
  • 67
  • 1
    "However, if possible, I'd try to avoid such style blocks in html altogether." Yes, please do. – roydukkey May 25 '15 at 10:51
  • In some of the pages I have to overwrtie styles written for telerik controls. they may change page by page. I have to take care of that. and it is the only way for it. It is not giving any trouble to me but I just wanted to know the technical aspects behind this warning. – captainsac May 25 '15 at 10:54