The first code snippet below uses the Attributes collection of the tag (implemented as an HtmlControl object) to reference its standard HTML attributes. This method gives you programmatic access to any of the HTML attributes that you normally hard-code into your tag.
The second method uses the Style object property of the HtmlControl object. By making calls to the Style object property's Add method, you can add custom styles to your tag. These are implemented as an inline style tag when it is rendered to the browser.
Because of this, you may want to research whether the style you are going to implement is compatible with the browser you are targeting.
The techniques used here can be used to set the properties of any HTML control that does not have a Server Control equivalent. An example would be the
tag.
Sample code 1: Use the "Attributes" collection of the body tag
<%@ Page Language="C#" %>
This is the body text.
Sample Code 2: Use the "Style" collection of the body tag
<%@ Page Language="C#" %>