li, p and inheritance

This forum is for all Flare issues related to styles, stylesheets and XML.
Post Reply
oceanclub
Sr. Propeller Head
Posts: 277
Joined: Thu Oct 10, 2013 4:45 am
Location: Dublin

li, p and inheritance

Post by oceanclub »

How does CSS inheritance work with li and p? I had set some margin and padding properties on body, assuming that li and p inherit these. Looking at my output this does not seem the case. Where do I set these to avoid having to set them in duplicate - or is this possible?

P.
TaylorTalkington
Jr. Propeller Head
Posts: 5
Joined: Tue Nov 28, 2017 7:34 am
Location: USA

Re: li, p and inheritance

Post by TaylorTalkington »

I can reproduce your issue in a new Flare project.

Looking at the CSS reference over at w3schools for the margin and padding properties, they both are not inherited (Inherited: No), so by default those values will not cascade down to child elements.

Playing around with styles, setting either to inherit doesn't work either because browsers (Chrome at least, and it looks like MadCap's internal renderer is also doing it) have a default 'user agent style' that sets the margin and the padding may be set somewhere else:
user agent p styles.png
Setting the margin/padding directly on p does work as expected, but you obviously wanted to avoid that.

I couldn't find a good way of doing this, but maybe this will point you in the right direction.
You do not have the required permissions to view the files attached to this post.
NorthEast
Master Propellus Maximus
Posts: 6363
Joined: Mon Mar 05, 2007 8:33 am

Re: li, p and inheritance

Post by NorthEast »

oceanclub wrote:How does CSS inheritance work with li and p? I had set some margin and padding properties on body, assuming that li and p inherit these. Looking at my output this does not seem the case. Where do I set these to avoid having to set them in duplicate - or is this possible?

P.
You can set properties for a number of tags at the same time, by separating them with a comma.

Code: Select all

li,
p
{
...
}
ChoccieMuffin
Senior Propellus Maximus
Posts: 2632
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Re: li, p and inheritance

Post by ChoccieMuffin »

And if you want to have a p inside a li NOT having the margin/padding you've applied to an ordinary p, use a complex selector:

For example, if you have 20px margin on a p and a li but you don't want the p inside a li to be indented by 40px:

Code: Select all

li, p
{margin-left: 20px;
}

li p
{
margin-left: 0;
}
Hope that helps. And definitely worth looking at the w3schools.com site - bookmark it, you'll find you keep popping back there.
Started as a newbie with Flare 6.1, now using Flare 2023.
Report bugs at http://www.madcapsoftware.com/bugs/submit.aspx.
Request features at https://www.madcapsoftware.com/feedback ... quest.aspx
Post Reply