Community

How do you style block headers - like each word a different color (formerly done with CSS class tags)?

Hi,

I hope I'm explaining this right.

I'm just looking for a way to be able to style the block headers in a way that I define inside of Drupal itself.

i have most of my block headers in a static site that have various colors for each separate word - I do this with a "span" and 'class" for each word, to make the color change in the CSS file.

How do I approach the same thing with Drupal?

Meaning, how do I tell i to style the second word purple, or the third word blue, or something like this, to match the theme of my design?

Thanks a lot,

- Paul

Comments

---

I would say you need to modify your page.tpl.php template and write some php to parse the title into individual words. Then add in a span class to each word (most likely in a loop of some sort), and throw it back together to display.

Can I not just put a span in the block header itself?

Can I not just put a span in the block header itself?

---

Do you want to target each word or the entire header? If you want the entire header yes you can wrap it in a span.

Specific words. I have half

Specific words.

I have half the header in one color, half in another.

So I'd need to put the span/class tag in a place where I could choose where I want the words to be a different color.

Thanks. and sorry for the trouble.

---

Just wrapping a span around the title would wrap it around the entire title (all words). If you want to split it up you'll need to write your own php code to do so (unless there's a module that happens to add classes to each word of a title, which I doubt).

Parse the words by the spaces, track how many words there are, then apply one class to the first half, and a second span to the second half.

nobody click here