-1

I want to create an element by P tag which must be like this:

enter image description here

I create this by adding top and bottom border to a P tag but there is a little space between the content and left border of P tag: some thing like this:

enter image description here

How can I remove this space and start content just after tag boundry starts?

this is my Code:

     <p style="color:#e72b78; font-weight: bold; border-top:#e72b78 2px solid; border-bottom:#e72b78 2px solid; ">
                        Primary end point:
     </p>
Alohci
  • 78,296
  • 16
  • 112
  • 156
Navid_pdp11
  • 3,487
  • 3
  • 37
  • 65

1 Answers1

1

Not sure if it fits but just set the width of the p to fit-content.

Edit: Check the browser support for fit-content here: https://caniuse.com/?search=fit-content

p {
color:#e72b78; 
font-weight: bold; 
border-top: currentColor 2px solid; 
border-bottom: currentColor 2px solid;
width: fit-content;
width: -moz-fit-content;

}
<p>
                    Primary end point:
 </p>

Edit: If you want the border to have the color of the font you can use the currentColor variable.

<p style="color:#e72b78; 
    font-weight: bold; 
    border-top: currentColor 2px solid; 
    border-bottom: currentColor 2px solid;
    width: fit-content;
    width: -moz-fit-content;
    ">
                        Primary end point:
     </p>

If you have to support IE11 as well you can set display: inline for the p tag but that may cause some alignment issues what you have to fix as well:

<p style="color:#e72b78; 
    font-weight: bold; 
    border-top: currentColor 2px solid; 
    border-bottom: currentColor 2px solid;
   display: inline;
    ">
                        Primary end point:
     </p>
Zsolt Balogh
  • 595
  • 1
  • 5
  • 12