Is it possible to set a div to always contain a particular paragraph style?

This forum is for all Flare issues related to styles, stylesheets and XML.
Post Reply
JeanLR1970
Propeller Head
Posts: 17
Joined: Tue May 24, 2022 2:35 am

Is it possible to set a div to always contain a particular paragraph style?

Post by JeanLR1970 »

I have divs set up for Notes, Examples and Warnings. These always start with a paragraph styles with coloured text for Note, Example and Warning.
To save me having to do it manually every time, is there a way to set up the style in the stylesheet so when I add the div it already contains the <p> for the coloured text?
andrewb
Propeller Head
Posts: 16
Joined: Sun Aug 16, 2015 3:40 pm
Location: Brisbane, Australia

Re: Is it possible to set a div to always contain a particular paragraph style?

Post by andrewb »

It certainly is possible. This was previously answered here: viewtopic.php?t=29647. Here is their example using H1 followed by a p tag with the class "together":

Code: Select all

h1{
	mc-next-tag: p;
	mc-next-class: together;
}
Psider
Propellus Maximus
Posts: 902
Joined: Wed Jul 06, 2011 1:32 am

Re: Is it possible to set a div to always contain a particular paragraph style?

Post by Psider »

I think that will style the p following the div, not the p inside the div.

What you could do is set up each div as a snippet, then after you insert the snippet, right-click on it and select Convert to text

Or, you could use a complex selector, to style the first paragraph

It would look something like this in your stylesheet.

div.Warning p:first-child {
color: yellow;
}

This says, for the p that is the first tag inside the Warning div, make the font colour yellow.

You can see an example here:
https://developer.mozilla.org/en-US/doc ... irst-child
Post Reply