skip to Main Content

I need to wrap the border around the text so it fits and center the text at the same time. I found a temporary solution in using display: inline; makes the border fit the text but when I try to use text-align: center; it does not align it. So I found using display: block; fixed it but I can’t use display block and inline at the same time so I am stuck.

<p1 class="frequently">Frequently Ask Question</p1>

.frequently{
    color: rgb(232 87 61);
    border: solid rgb(251 244 239);
    border-radius: 2rem;
    display: block;
    text-align: center;
}

2

Answers


  1. Just add width: fit-content to your css, it works.

    Login or Signup to reply.
  2. Replace display: block with text-align: center. Or you can use display: flex; justify-content: center

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search