1. Back To Blog

ASP.NET interview questions: -Explain CSS (Cascading Style Sheet) and what are steps to create a CSS in ASP.NET?

ASP.NET interview questions: -Explain  CSS (Cascading Style Sheet) and what are steps to create a CSS in ASP.NET?

CSS (Cascading Style Sheet): - Cascading Style Sheets (CSS) is a style sheet language used to describe the presentation semantics (the look and formatting) of a document written in a markup language.

In simple words CSS (Cascading Style Sheet) is used to apply layout and visual style of elements.

CSS (Cascading Style Sheet) is supported by almost all the browsers.

Now, let's create a simple example to see how exactly we can add a CSS (Cascading Style Sheet) file in your ASP.NET application.

In order to see it practically just follow the following steps.

Step1: - Create a simple ASP.NET web application for that just go to >> File >> New >> Project >> Web >> Select ASP.NET Empty Web Application.






Step2: - Now add a simple WebForm page in to your Web Application for that just go to >> Solution Explorer >> Right Click on your Project >> Add >> New Item >> Select WebForm.




After adding the WebForm page in to your application, now design your page like below diagram.




Step3: - This is the most important step while using the CSS (Cascading Style Sheet), in this step we just need to add a style sheet for that just go to >> Solution Explorer >> Right Click on your Project >> Add >> New Item >> Select Style Sheet.




Now, let us assume that we have change the background color and text color of the Button control and the TextBox control. In order to achieve the above point we have to add below code snippet in to your StyleSheet1.css file.

.buttonInsert color:Black;background-color:Green;}
.buttonDelete color:Black;background-color:Red;}
.buttonUpdate color:Black;background-color:Yellow;}
.text color:Black;background-color:Blue;}


In the above code snippet you can clearly see that I have created three different styles for the button control and a single text style for the TextBox control.


Step4: - Now, let's see how exactly we can use CSS in to your Web Application.





Now, when you run your web application you will see the result like below diagram.




In the above diagram of the result you can clearly see the effect of the CSS declared on the described controls.


Similarly, you can doo a lot with the CSS (Cascading Style Sheet) to make your page attractive and helpful to the user.



See the following video on questions asked in C# and .NET interviews: -



Get more materials on ASP.NET interview questions

Regards,

See more stuffs on author's blog for ASP.NET interview questions 

 

Shiv Prasad Koirala

Visit us @ www.questpond.com or call us at 022-66752917... read more

We are on Social