Online Training for Asp.net MVC Web Designing Development, MS SQL, Digital Marketing

CSS Best Practice, Best way to write CSS


Best way to write CSS Style in your Web Application
Now you have an idea what is CSS and how to write CSS Syntax!
But before you learn more CSS example we want you to understand some best practices of writing CSS Style Sheet.

There are three ways you can write CSS
  1. In Line
  2. In File
  3. Using External Reference
Every approach has some advantage and disadvantage, but if you know when to use what, then you will be able to design the best optimized web application.

Now here we show you some example of each approach and explain when to use them.

CSS in line

In-line CSS you can write when some small additional changes required, the more you can avoid this practice, is good for web page
Here is an example
<div style="padding:10px;">

</div>

CSS in File

In-File is basically writing css class or id on current html document and uses that class on some element of current document, not really a good practice but sometimes we do, especially when you know that particular class will not be used in any other document! But try to avoid this practice.
this is how you can write css class on same page.
<style>
.splDiv
{
padding:6px;
border-bottom:solid 1px #cbcbcb;
}
</style>

CSS External Reference

External reference is basically writing a CSS in a different file and adding the file on your webpage, so the page remain clean, also the classes are re-usable in other WebPages
Here is how you can add reference of css file in your webpage
<link href="~/Content/etg_style.css" rel="stylesheet" />
In earlier article we have already explained how to create a .css file


Comment
Name Email Website
Subscribe
 
CSS Best Practice, Best way to write CSS

Group Training