i have created a view block and added some fields to it,i want to change the style of those fields with css, is there a way that i can do it. "Thank you"

2 Answers 2


Click on the field you want to add a css class to, select style settings, and customize field html and check create a css class. Give it a name and simply add the class to the css file of your theme

enter image description here

  • i did that but it wont work Commented Jul 17, 2013 at 9:47
  • class is not inheriting from another class. Commented Jul 17, 2013 at 10:00
  • i am using div and i also tried -Use Default- Commented Jul 17, 2013 at 10:06
  • yes i have cleared the cache . Commented Jul 17, 2013 at 10:16
  • 1
    Have you inspected the views output to check if the class you have added is added or not? If class is added, then only two possibilities I can think off - The '.css' file has not been included in that page where you are displaying the result, or, the css code has been overridden at some point.If the class itself is not getting added then two possibilities I can think off are - The particular views theme has been overridden in template.php or in views tpl file, or, you have added class in one of the multiple views and accessing another. Hope it helps
    – dhrubaj
    Commented Jul 17, 2013 at 12:25

If it's only one or two block displays of views, consider calling template_preprocess_block() in your template.php file, adding the class(es) you want to the block level, then styling the fields within the block using specificity in your CSS selectors. Example:

    function MYTHEME_preprocess_block(&$variables) {
        if (your condition here to target the blocks you want) {
            $variables['classes_array'][] = 'yourClass';

While it would be best to have Drupal attach the CSS classes for you, a second option would be to use jQuery's .addClass() method, especially if it's only one or two blocks. Example:


Hope that helps!

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.