-3

I have code like this

<p><span>On this day,<div class="underline-text">Sunday</div>,we, the undersigned:</span></p>

and my css

.underline-text {
    display: inline-block;
    border-bottom: 2px solid black;
    width: auto;
}

But my problem is when i run this code, is show like this :

On this day,

    `Sunday,we, the undersigned:`

What i need is like this :

`On this day,Sunday,we, the undersigned:`

How i do that way???? NOTE : I'm using bootstrap 3.

UPDATE : Works, i was stupid so i'm changing <div> to <span>. Thanks you all for the answer.

Why i got -2 vote??? Wat's wrong with my question??? I just asking simple question, and i kno i'm so stupid cause i'm using inline-block on span. But why i got minus for this???

Wolfzmus
  • 463
  • 1
  • 10
  • 23

3 Answers3

1

Make this adjustment:

On this day, <span class="underline-text">Sunday</span>,we, the undersigned:

A div inside a p element is invalid HTML. The paragraph element closes before the div element begins.

Here's how the browser renders your code:

enter image description here

For a complete explanation of this behavior see: https://stackoverflow.com/a/41538733/3597276

Community
  • 1
  • 1
Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701
0

<p> or <span> tags can't contain block-level elements inside them. Most browsers will split it into 2 separate paragraphs. Check this answer: https://stackoverflow.com/a/5441670/6424295

Maybe try using a<div> instead of a paragraph and get rid of the <span> tags, as I don't think they're really doing anything.

Community
  • 1
  • 1
Emilio Venegas
  • 546
  • 5
  • 22
0

Yes. It should be like this:

.underline-text {
    display:inline-block;
    border-bottom: 2px solid black;
    width: auto;
}
<div>
<p>
     
     On this day,<span class="underline-text">Sunday</span>,we, the undersigned:
     
</p>
</div>
ThinhLe
  • 409
  • 1
  • 3
  • 12