Ankit Chauhan
Ankit Chauhan

Reputation: 2405

how to set font for components using style sheet in c#?

stylesheet.css

body
    {
        font-family:Tahoma;
    }
    Label
    {
        font-family:Freestyle Script;
    }
    Hyperlink
    {
        font-family:Times New Roman;
    }
    TextBox
    {
        font-family:Tahoma;
    }

index.aspx

<link rel="Stylesheet" href="StyleSheet.css" type="text/css" />

Its not being afffected for hyperlink & label and not setting different font for both.

My components are in

Upvotes: 0

Views: 1258

Answers (3)

Flowerking
Flowerking

Reputation: 2581

ASP.NET renders html at client side and css is applied to html. You cannot use HyperLink , Label etc.

Label renders to <Span>
Hyperlink to <a>
TextBox to <Input>

try

a
{
    font-family:Times New Roman;
}
input
{
    font-family:Tahoma;
}

Instead, its better to assign ID's to them and use the ids to apply css.

Upvotes: 1

reshma k
reshma k

Reputation: 544

u can assign class to controls in aspx file as

<asp:TextBox ID="txtName" runat="server" CssClass ="txtInput" />

and in css file

 .txtInput
   {
     font-family:Tahoma;
   }

Upvotes: 0

Icarus
Icarus

Reputation: 63966

It's label, not Lable. Use

a
{
  ...
}

Instead of hyperlink.

Upvotes: 0

Related Questions