Reputation: 331
So i have this label in my master page and i would like change it's color and it's font :
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
my css code :
#Label1{
font-size:36px;
color:red;
}
and it doesn't work. Can someone explain why this doesn't work ?
Upvotes: 1
Views: 1649
Reputation: 3706
Set the ClientIDMode property to Static like this:
<asp:Label ID="Label1" ClientIDMode="Static" runat="server" Text="Label"></asp:Label>
Then it will retain the same ID on the client side.
An ASP.NET Label renders as a HTML <span>
tag.
Alternatively just use the CssClass property of a ASP.NET control to set it's CSS class like so:
<asp:Label runat="server" ID="Label1" CssClass="label"></asp:Label>
Upvotes: 2