0

How do I remove space between paragrah and a specific html list? Based on image provided, I want the list to be moved up closer to the paragrah:

enter image description here

<p><strong>Reason</strong><br/>
As part of the change from the NHS, the following drugs are unable to be prescribed by the doctor and requires a special consultant to prescribe these medications:
    <ul class="nospaceabovelist">
        <li>Clonazepam</li>
        <li>Imitrex</li>
        <li>Amoxil</li>
        <li>Sensipar</li>
    </ul>
</p>

p + .nospaceabovelist li{
    margin: 0;
    padding:0;
  }
Tony S
  • 491
  • 6
  • 26
BruceyBandit
  • 3,978
  • 19
  • 72
  • 144
  • 4
    A list can't be nested into a paragraph but your css selector is looking for a list following a paragraph. Make it as a sibling, then set its margin. – Fabrizio Calderan Feb 25 '20 at 11:31

3 Answers3

0

Paragraphs cannot contain ul so you need to change the HTML.

Then just remove margins from both.

  p, p + .nospaceabovelist {
  margin: 0;
  padding: 0;
}
<p><strong>Reason</strong><br/> As part of the change from the NHS, the following drugs are unable to be prescribed by the doctor and requires a special consultant to prescribe these medications:</p>
<ul class="nospaceabovelist">
  <li>Clonazepam</li>
  <li>Imitrex</li>
  <li>Amoxil</li>
  <li>Sensipar</li>
</ul>
Paulie_D
  • 107,962
  • 13
  • 142
  • 161
-1

i think you search this :)

<html>
<head>

<style>
p
{
  margin: 0;
  padding:0;
  line-height: .75em;
}
ul
{
  margin: 0;
}

</style>
</head>
<body>
      <p><strong>Reason</strong><br/>
                As part of the change from the NHS, the following drugs are unable to be prescribed by the doctor and requires a special consultant to prescribe these medications:
                <ul>
                <li>Clonazepam</li>
                <li>Imitrex</li>
                <li>Amoxil</li>
                <li>Sensipar</li>
                </ul>
            </p>
</body>
</html>
Y.H
  • 53
  • 2
  • 8
-2

Add this in css:

p {
    margin: 0;
}

ul {
    margin: 0;
}
cjol
  • 1,485
  • 11
  • 26
  • These selectors are very general - although adjusting the margin is probably the right approach, you should specify more specific selectors instead of adjusting all margins across all `p`s and `ul`s. – cjol Feb 25 '20 at 11:42