How to make text align work for strong tag?

Viewed 904

I'm trying to justify the text inside the <strong>tag. I have added strong {text-align: justify;} which didn't work. Here is the link where I'm trying to run this example. https://codepen.io/vkdatta27/pen/abNQeoL. I also added strong {font-weight: normal;} and that worked. Only text-align is giving a hand. I don't want html to be changed even a bit. I want only css to be changed. Can anyone help me regarding this? My previous two questions were also regarding this issue but they were closed as there were no minimum details. I think above link gives you the sufficient requirements.

4 Answers

Add display: inline-block; to strong instead of font-weight: normal; work perfectly :)

Because, <strong> is an inline element per default. Meaning it has no width or height on its own but rather is exactly as big as its content. So you can try to add display property inline-block or block.

strong {
    text-align: justify;
    display: inline-block;// also works with display:block
}

strong {
  text-align: justify;
  display: inline-block;
}
think I have more power than he does. I think I could string together the wrestling and the grappling and the striking better than he can, and it will be the best fight
<br /><br />
<strong>WBC heavyweight champion Tyson Fury has applied pressure on his domestic rival, Anthony Joshua, to bypass any further obligations that stand in the way of a 2021 showdown.

  Fury is going to face Deontay Wilder in a trilogy fight on the tentative date of December 19.</strong>

You should specifie The CSS display:block or display:inline-block property to render the HTML element to box element.

Usually you would apply text-align: justify; to a parent block level element.

As you're applying it to an inline element (the strong tag) you need to set this to display: block; or display: inline-block.

strong {
    text-align: justify;
    font-weight: normal;
    display: block;
}
think I have more power than he does. I think I could string together the wrestling and the grappling and the striking better than he can, and it will be the best fight
<br /><br />
<strong>WBC heavyweight champion Tyson Fury has applied pressure on his domestic rival, Anthony Joshua, to bypass any further obligations that stand in the way of a 2021 showdown.

  Fury is going to face Deontay Wilder in a trilogy fight on the tentative date of December 19.</strong>

Related