While ASP.NET server controls make developing Web pages much simpler,
sometimes they don't output their HTML exactly the way you'd like them to.
That's where the Literal Web server control comes in. Unlike most
other controls, it doesn't add anything to the output.
Think about that for a second. Basically, the Literal control does nothing for us.
So... why would you want to use it?
You use the Literal control when you
want precise control over the HTML or text that is sent to the browser. Many
developers tend to use a Label control in situations when they should probably
be using a Literal control. The Label control works great when you're actually trying to
label something, but the problem with using it in other situations is that, the Label control
actually renders a span element around its content. In addition to adding to size of the resulting page,
the span element can actually interfere with a page's existing styles. The
Literal control doesn't add any HTML or text to the output. That way there's
nothing to interfere with you getting the page to look exactly the way you want.
At its most basic, a literal control looks something like this:
<asp:Literal id="litExample" runat=server />
and unless you assign a value to its Text property (either declaratively or via code),
the control won't render anything at all.
For more information on the Literal Web server control, check out the documentation on MSDN: