The difference between the Literal control and the Label control is that the Literal control does not add any HTML elements to the text. (The Label control presents a span element .) Therefore, the Literal control does not support any style attributes including position attributes. However, the Literal control allows you to specify whether to encode the content.
Encode content in the Literal control
The Literal control supports the Mode attribute, which is used to specify how the control handles the tags you have added. You can set the Mode attribute to the following values:
Transform. converts any tags added to the control to adapt to the protocol of the requesting browser. This setting is useful for rendering content to mobile devices that use other protocols other than HTML.
PassThrough. Any markup added to the control will be displayed in the browser as is.
Encode. The HtmlEncode method will be used to Encode any tag added to the control. This will convert HTML encoding into its text representation. For example, the <B> tag is displayed as & lt; B & gt ;. Encoding is useful when you want the browser to display without interpreting the mark. Encoding is also useful for security and helps prevent malicious tags from being executed in browsers. This setting is recommended when displaying strings from untrusted sources.
Literal cannot use styles. Location layout is troublesome.
You can add a Literal Web Server Control to the page when you want to set text programmatically without adding additional HTML tags. The Literal control is useful when you want to dynamically add text to a page without adding any elements that do not belong to the dynamic text. For example, you can use the Literal control to display the HTML read from a file or stream.
To display static text, you can use HTML to render it. The Literal control is not required. The Literal control is used only when the text needs to be rendered programmatically.