1

Is it possible to add custom HTML and CSS in views header and footer using the administrative UI? I am trying to add a header to my view but that is not giving me any option through which I can add HTML and CSS like the options which are given to us when we add fields in views. I have tried adding a header using Global Textarea but in this, we can only write HTML not CSS. Kindly tell how can we add HTML and CSS both to the header.

2
  • 1
    Is it D8 or D7? Commented Nov 13, 2018 at 7:06
  • 1
    Drupal delivers CSS through libraries. How to attach a library to a view see drupal.stackexchange.com/questions/205367/… Commented Nov 13, 2018 at 7:54

1 Answer 1

2

It isn't good practice to intermix HTML and CSS (embed CSS or use inline styles). As a rule CSS is kept separate in files in your theme, and some in modules.

Views allows you to define CSS classes for certain parts of the output, but you still have to keep the CSS rules and declarations in your theme.

If you don't have access to your subtheme for some reason or only want to apply tiny changes you can try CSS Editor. It gives you a place where to enter new CSS rules that will apply throughout your theme.

You still have to edit your Views output to include the custom HTML classes to elements you want to style, you can do that through Global Text area as you already found.

Many themes already assign a lot of classes to various Views parts, so maybe you already have classes relevant to your design and you can use them in custom CSS without adding new classes in HTML.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.