简体   繁体   中英

Asp.net link runat server w3c validator

when i run a link server side like this:

     <link runat="server" id="staticCss" 
href="....css?v=0" media="all" rel="stylesheet" type="text/css" />

asp.net renders it with

<link runat="server" id="staticCss" 
href="....css?v=0" media="all" rel="stylesheet" type="text/css" ><link>

and this fails the w3 validation

Stray end tag link.

becasuse link tag can't end with link but must end with /

How can i avoid it?

As far as I know, it can't be avoided. These are the alternatives that you have:

  1. Use a static link tag without the server processing, if you can
  2. Ignore the validation error: browsers handle this markup well and you shouldn't have any issues on your website
  3. Use a .net literal to spit out the markup as text: this way you are in total control of the formatting

I have been struggling with .net generated html for a long time, it can be very frustrating. If anyone knows of other ways to solve this I would be very interested to learn.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM