Forum
Adding a class to text area that is output on to the page
Hi,
I have created a template to use with the Gallery App (Until I can work out a way to build my own possibly). What I would like to do is to use the description text, but give it a class so that when it is rendered on my page it uses a class I have set in my CSS. Is this possible?
My template looks like this:
<perch:before>
<div class="headings">
<span class="headerText"><perch:gallery id="albumTitle" /></span>
</div>
<div class="photos">
<perch:gallery id="description" type="textarea" class="containerText"/>
</perch:before>
<img class="big" src="<perch:gallery id="small" />" alt="<perch:gallery id="imageAlt" />" />
<perch:after>
</div>
</perch:after>
You can see what I have attempted to do but it doesnt seem to have worked.
Simply wrapping the description tag in a div with the class will achieve the same thing.
Thanks Jonathan, I did that in the end I was hoping to only apply if to the P it self but not to worry
Glad to hear it Stefan. The reason that applying a class to a textarea fieldtype won't work in practice is that the textarea could potentially contain any number of html elements. I always try to think "what can the client do to break this?":)
You can now use
.containerText ~ p
(or any number of pseudo classes) to target your p tag(s).Yes thanks Jonathan, that's a great way to be thinking, I try to do that in my own job when working on new projects