0

What can I do to make it so that a border is only as wide as the p element it is applied to in CSS?
I also want to make it so that it auto-changes the size of the border if I were to change the text?

This is what it looks like without any fixing: 1

This is what it looks like when I manually change the size and then change the text: 2

I just want it to change depending on the length of the text. Thanks!

ghlow
  • 3
  • 1

1 Answers1

0

Display inline-block will do the trick.

div p{
  border: 1px solid #000;
  display: inline-block;
  padding: 2px 4px;
}
<div>
  <p>Home</p>
<div>
Dmytro Cheglakov
  • 744
  • 4
  • 14