0

On one project client is requesting to change css file code to some thing like this.

example:

div.fp_grid table td.col2 
{ text-align: center; } 
div.fp_grid table td.col2 .body_box 
{ margin: 0 auto; }

becomes:

div.fp_grid { td.col2 { text-align: center; .body_box { margin: 0 auto; } } }

But it seems invalid formate of CSS i little guidance will be appreciated what are your thoughts.

4
  • Why does your client want that? Commented Oct 18, 2013 at 11:57
  • Seems like with minifying a css file Commented Oct 18, 2013 at 11:58
  • 2
    You're right; that is invalid CSS. There are CSS pre-processors such as Less and Sass that use syntax like this, but if they're using one of them, they should tell you. If they're not using one of then they're asking for invalid CSS. Commented Oct 18, 2013 at 11:59
  • @putvande the clients wants to make it easy for him to remove the extra unused css later , so i want to know how can this format be validated as it is not working for me the the page wont pick css form this formating. Commented Oct 18, 2013 at 12:00

3 Answers 3

1

The CSS you have there is syntactically correct. The format they seem to be asking for is consistent with nesting in a CSS pre-processing language like SASS, see http://sass-lang.com/guide for example.

Sign up to request clarification or add additional context in comments.

Comments

1

This indeed faulty CSS.

CSS does not use nested selectors.

The markup you have above is correct, tho usually you would write css like this:

#selector {
    margin: 0 auto;
    padding: 0 auto;
}

this improves readability so that it will be easier to change in the future.

You could always remove excessive whitespace in CSS files using an online CSS compression tool.

CSS will not give any errors on invalid markup tho, it just skips it as it does not know what it means, therefore your box would be unstyles if nested.

Comments

1

It's invalid css, it's CSS-processor. You can try this service : http://css2sass.heroku.com/

Put your first code block, then click convert 2 SCSS, and you will get the second block.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.