Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I apply inline CSS to an ASP.NET server control?

Tags:

css

asp.net

Based on a simple test I ran, I don't think it's possible to put an inline <style> tag into an ASP.NET server control. The style did not end up rendering to the output HTML. Even if it was possible, I'm sure it is bad practice to do this.

Is it possible to do this? I can see it being useful for quick prototypes that just have 1 or 2 CSS classes to apply.

like image 558
Jason Z Avatar asked Sep 18 '08 13:09

Jason Z


People also ask

How can we implement inline CSS?

To add inline CSS in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with CSS properties such as font-family, font-style, text-decoration, direction, etc. Just keep in mind, the usage of style attribute overrides any style set globally.

What is CSS explain steps to include CSS in ASP.NET Web application?

CSS describes the style of an HTML document. CSS describes how HTML elements should be displayed. External stylesheets are stored in CSS files. CSS is used to define the styles for your Web pages, which includes the design, layout and the variations in display for the different devices and the screen sizes.

What is inline CSS with example?

Inline CSS: Inline CSS contains the CSS property in the body section attached with element is known as inline CSS. This kind of style is specified within an HTML tag using the style attribute. Example: html.

Is it OK to use inline CSS?

Inline styles, while they have a purpose, generally are not the best way to maintain your website. They go against every one of the best practices: Inline styles don't separate content from design: Inline styles are exactly the same as embedded font and other clunky design tags that modern developers rail against.


1 Answers

Intellisense won't give you hints but you can do this:

<asp:Label ID="Label1" runat="server" Text="Label" style="color:Red;"></asp:Label>
like image 69
NakedBrunch Avatar answered Oct 15 '22 15:10

NakedBrunch