What is CSS – write CSS first time

What is CSS – write CSS first time

CSS is a commonly used term in the web world. What is CSS? Have you ever had this question as a newbie? Well, many new web programmers come across this term in their development profession and initially understand absolutely nothing about it.

So, I thought I could give a briefing on what is CSS actually. I too had problems understanding CSS when I was a first timer. HTML is like the blue-print of a webpage. Using HTML, you actually tell the web browser which element must be at what position.

Learn more HTML in my article – What is HTML – how to write HTML.

The sequence and synchronization of elements on a webpage is arranged by HTML. Since the introduction of HTML 4.0, the coding standards have been raised to next levels. Several styling definitions were used in HTML element tags previously. However, these were deprecated in the recent markup models and the introduction of style definitions was proposed.

So, what is CSS actually? CSS or cascading style sheets are external files linked to the HTML documents. These files contain style definitions for elements on the respective HTML markup. These style definitions can be done using element selectors or by using the basic element names. Here’s an example –


    max-width: 100%;border: none;           /* Styles for all image elements */

    background: url('logo.png') 0 0;        /* Styles for the element with id logo */

    border-radius: 15px;                    /* Styles for all the elements with class radius15 */
    -webkit-border-radius: 15px;
    -moz-border-radius: 15px;
    -o-border-radius: 15px;
    -ms-border-radius: 15px;



What is CSS and inline styling?

When you ask yourself – what is CSS? You can actually have a very directive answer. But, CSS is basically used for styling the HTML elements. Though inline styling is a bad practice, but still comes handy some times when you need to specify some short styling for a single element (you can also achieve this using an id selector for the element). Even if inline styling is not used nowadays in modern coding systems, knowing the concept is important.

Inline styling refers to writing CSS rules for elements with a style attribute. The style attribute is mentioned in the tag itself. This ensures that the particular element gets the style rules. But, keep in mind that only that particular element gets the style; not all similar DOM elements. Here’s an example of inline styling –


<div style="color: blue"></div>

Another styling option is defining styles in the head region. So, when you write your HTML head section, include a style section. Within the style opening and closing tags write all the CSS rules just like as in a CSS file. However, this method is also not recommended for professional coding standards. The drawback is very simple. Each HTML files would require a style section separately. Separate CSS files behave as global declarations. Because, you can link the same style rules to multiple HTML files. Thus reducing lines of code and server load.


What is CSS best practice?

For best CSS coding, you can refer to the W3Schools website for detailed description on each attribute. However, I am mentioning some of the most basic rules that could be followed while writing your style-sheets. These rules, if followed, will yield you the best results for the orientation and display of your page.

The following piece of code can be handy to

–          Set all borders and margins for the body tag to 0. This can be useful because often your website might start displaying with a little gap between the browser and the main content. This space shall be removed.

–          Image elements take up blue borders in IE browsers. This can be removed.

–          All hyperlinks on the page can be customized to remove underlines and change the default blue color.

–          Website content will be centered in case of fluid width, instead of getting aligned to the left corner.


Also, remember to implement the following technique. This is a good practice and reduces file size –

/* Always keep your structure like this */


// styling here


/* Never make your structure like this */



// styling here


Other than this, there are various other techniques that you can use to optimize your CSS content. LESS is an option to minify file size by writing conditional CSS declarations with variables and operands. This reduces your CSS files to a large extent.

You can also minify your CSS files through other popular minifying solutions on the internet.

What is CSS latest? Read along!

What is CSS3?

CSS3 is a fantastic solution for web developers to implement more design and animation work using plain CSS codes. CSS3 works mainly on the modern browsers and has very little compatibility with slightly older versions.

You can implement CSS3 in your website with some cool effects like element rotation, rounded corners, and animations on elements’ style properties and much more. This does not require any external file or includes. Straight and simple – if the browser can render your CSS3 rules then it’s displayed otherwise the fallback rules are applied.

However, for a second backup in case your CSS3 fails, you can try CSS3 Please by Paul Irish and Jonathan Neal. This is a magnificent solution to provide cross browser fixes to CSS3 failures in older browsers.

Comments are closed.