Question:

Does it matter where classes lie when reordering them in a CSS?

by  |  earlier

0 LIKES UnLike

If I have a CSS with various class selectors and elements strung within it, does it matter what position in the CSS those classes are placed?

I thought it didn't, but I must be mistaken. I repositioned a few selectors to different areas of the CSS and it seems to have distorted the resulting theme. Is that because I repositioned them, or may I have accidentally deleted a vital portion of the css?

 Tags:

   Report

2 ANSWERS


  1. Will not really but it depends, if you use an applet in your web page it which works with you CSS ir would be a great matter.


  2. The C in CSS stands for "Cascading".

    What this means is that if you define a certain style to an element, and at a later position to create a style for its container, that second style *may* override the first, depending on how the classes and selectors are used.

    Normally, when using classes and IDs, a class style should not be changed, regardless of the order in the CSS.

    Check for overlaps, double names or incorrect selectors... if you use Firefox, and you install the Web Developer Toolbar add-on, you can hover over elements and see their IDs and class names, giving you a very good visual indication of the hierarchy of a document.

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.