Home > Net >  How to add style to after class P Tag
How to add style to after class P Tag

Time:10-31

need to add display: inline; style for First P tag.

<div class="showques">
  <div class="lab_tre">A</div> &nbsp;
  <p> Text1 </p>
  <p>Text 2 para </p>
</div>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

How can do this

CodePudding user response:

You can target the first p type element that is a child (but not grandchild) of .showques class using the first-of-type pseudo class selector.

However, since items before and after the first p element has display: block; by default, they would still show in different lines.

.showques > p:first-of-type {
  display: inline;
}
<div class="showques">
  <div class="lab_tre">A</div>
  <p> Text1 </p>
  <p>Text 2 para </p>
 </div>
<iframe name="sif2" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

CodePudding user response:

In your CSS,

p { display: inline } will display all P tags in-line.

.showques p { display: inline } will alter only the P tags inside your 'showques' box

  •  Tags:  
  • css
  • Related