I have found that, there are times when you need to deal with HTMLControls, using ASP.Net or SharePoint in code, rather than with a design surface.

The situation then becomes how to deal specifically with CSS styles within the code. Naturally, it’s fairly straightforward in the mark-up, either doing it directly in the tags, or in an external stylesheet, but it’s a bit different within the code itself. And it’s definitely different than how to deal with ASP.Net controls.

Here are a few basic items that should get you started:

C#
HtmlTable tbl2 = new HtmlTable();
tbl2.BgColor = "#F0F0F0";
tbl2.CellSpacing = 1;
tbl2.CellPadding = 1;
tbl2.Style["border"] = "Solid 1 #E0E0E0";
HtmlTableRow row1=new HtmlTableRow();
row1.BgColor = "#507CD1";
row1.Style["font-size"] = "8pt";
row1.Style["font-family"] = "Arial";
row1.Style["font-weight"] = "bold";
VB.Net
Dim tbl2 As HtmlTable = New HtmlTable
tbl2.BgColor = "#F0F0F0"
tbl2.CellSpacing = 1
tbl2.CellPadding = 1
tbl2.Style("border") = "Solid 1 #E0E0E0"
Dim row1 As HtmlTableRow = New HtmlTableRow
row1.BgColor = "#507CD1"
row1.Style("font-size") = "8pt"
row1.Style("font-family") = "Arial"
row1.Style("font-weight") = "bold"