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?
Is it possible to set a div to always contain a particular paragraph style?
-
JeanLR1970
- Propeller Head
- Posts: 17
- Joined: Tue May 24, 2022 2:35 am
Re: Is it possible to set a div to always contain a particular paragraph style?
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;
}Re: Is it possible to set a div to always contain a particular paragraph style?
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
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