If p follows a ul, then

I forgot how to do this.

How do I tell CSS, “If a < p > immediately follows a < ul >, then add extra top padding.”

then your HTML is invalid.

a <ul> must always be followed by an <li>

or did you mean a <p> immediately followed by a <ul> which would be p+ul

Don’t be so literal. :smirk:

I meant…

<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>
<p>
Some stuff here...
</p>

Yeah, well the lingo can be a bit confusing. :slight_smile: you can have two ELEMENTS following each other ( as in after you close the UL, there is a P), or two ( open tags) following each other <UL><P> which is a no-no.

Anyways. What you want is a SIBLING SELECTOR…‘+’… (since the UL and the P are adjacent siblings).

ul+p {.. extra padding}

hope that helps

Strange, I tried that before posting here and I didn’t see a change. (Caching issue?)

Then I tried it again last night, and it seems to have worked.

Hmmm.

Thanks!

You have to be very literal when dealing with computers.

4 Likes

You also have to be literal as you don’t really know what the user’s skills levels are.
I would not discount a person out there using <p> instead of <li> because: creativity & not knowing any better.
It is a damned if you do & damned if you don’t thing.

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.