Share via


xhtmlConformance Element (ASP.NET Settings Schema)

Configures XHTML 1.0–conforming control rendering.

configuration Element (General Settings Schema)
  system.web Element (ASP.NET Settings Schema)
    xhtmlConformance Element (ASP.NET Settings Schema)

<xhtmlConformance mode="Transitional|Legacy|Strict"/>

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes

Attribute

Description

mode

An optional String attribute, which specifies the XHTML rendering mode for an ASP.NET application. The mode can be one of the values listed in the following table. The default is Transitional (XHTML 1.0 Transitional).

Value Description
Transitional XHTML 1.0 Transitional
Strict XHTML 1.0 Strict conformance
Legacy Reverts a number of rendering changes made for conformance to the v1.1 rendering behavior.

Child Elements

None.

Parent Elements

Element

Description

configuration

The required root element in every configuration file that is used by the common language runtime and .NET Framework–based applications.

system.web

Specifies the root element for the ASP.NET configuration settings in a configuration file. Contains configuration elements that configure ASP.NET Web applications and control how the applications behave.

Remarks

This setting has an effect only if the controlRenderingCompatibilityVersion attribute of the pages element in the Web.config file is set to 3.5 or if the Web site targets ASP.NET 3.5 or an earlier version. (For information about how to target specific versions of ASP.NET, see .NET Framework Multi-Targeting for ASP.NET Web Projects.) Otherwise, ASP.NET renders HTML as if the xhtmlConformance setting is set to Strict, regardless of the actual xhtmlConformance setting.

When the controlRenderingCompatibilityVersion attribute is set to 3.5 or the Web site targets ASP.NET 3.5 or an earlier version, the default xhtmlConformance mode is Transitional. However, under some circumstances, you might not want ASP.NET to render XHTML markup. This is typically true when you have existing pages that rely on elements or attributes that would ordinarily be prohibited by XHTML. In such cases you can set the xhtmlConformance mode to Legacy.

Note

Legacy mode does not change all HTML rendering to the way it was done in ASP.NET 1.1. Only rendering changes that are likely to break existing applications are reverted to their old behavior. There is no mechanism to revert all changes made to comply with the XHTML specification.

Default Configuration

The following default xhtmlConformance element is not explicitly configured in the machine configuration file or in the root Web.config file, but is the default configuration returned by an application that targets the .NET Framework version 3.5 or earlier versions.

<xhtmlConformance mode="Transitional"/>

Example

The following code example switches the rendering mode to conform to the XHTML 1.0 Strict standard. The primary change that occurs is that the name attribute is no longer rendered on the <form> tag.

<xhtmlConformance mode="Strict"/>

Element Information

Configuration Section Handler

XhtmlConformanceSection

Configuration Member

XhtmlConformance

Configurable Locations

Machine.config

Root-level Web.config

Application-level Web.config

Web.config

Requirements

Microsoft Internet Information Services (IIS) version 6.0

Microsoft .NET Framework version 2.0

Microsoft Visual Studio 2005

See Also

Tasks

How to: Configure Specific Directories Using Location Settings

How to: Lock ASP.NET Configuration Settings

Reference

system.web Element (ASP.NET Settings Schema)

configuration Element (General Settings Schema)

System.Configuration

System.Web.Configuration

Concepts

ASP.NET Configuration File Hierarchy and Inheritance

Securing ASP.NET Configuration

ASP.NET Configuration Scenarios

.NET Framework Multi-Targeting for ASP.NET Web Projects

Other Resources

General Configuration Settings (ASP.NET)

ASP.NET Configuration Settings

ASP.NET Web Site Administration

ASP.NET Configuration Files

ASP.NET Configuration API