tags:

views:

39

answers:

1

Background: Sorry if this is an obvious question. But I have no experience whatsoever with asp.net... Im just starting out with asp.net mvc without passing through webforms at all...I do have experience with web developing but with php+codeigniter... anyway.

Question: whats the purpose of having the runat attribute inside the head tag of my html??... should I remove it?

thanks in advance.

+3  A: 

Because, if you're using Master Pages, you can give yourself the ability to add further meta-data to the <head> tag by adding the runat attribute.

It's also used to inject Javascript references to the head tag for ASP.NET AJAX (and custom script injection that you might create on your page via ScriptManager).

EDIT

As the comments have pointed out, this is needed so that you can modify any of the contents of the <head> group in your code. I listed two of the more complex scenarios.

Justin Niessner
I believe you need this if you want the Page.Title property to render as a <title> tag.
David
It not specific to master pages. Modifying anything in the head elements requires the head to have a runat="server".
Svend
its just that I have noticed that adding that attribute messes up the linebreaks in my html markup.. I like to be able to look at the source and with that attribute all my link/css tags appear next to each other instead of one on top of the other one....
NachoF
i find that relative links to css files are corrected when the head has the runat.
Matt Sherman