0

I want to remove the space between texts and div inside. There's a picture of what I mean under space between text and div.

image

That space is really annoying. There is the style sheet and html:

div {
  display: inline-flex;
  line-height: 1;
  border: 2px solid rgb(204, 33, 33);
}

p {
  margin-inline: 10px;
  font-size: 30px;
  border: 2px solid rgb(204, 33, 33);
}
<div>
  <p>text</p>
  <p>text</p>
</div>
j08691
  • 204,283
  • 31
  • 260
  • 272
RolandHU
  • 3
  • 2

2 Answers2

1

margin-inline: 10px; this cause the issue you were facing, remove that and you get what you want.

div {
    display: inline-flex;
    line-height: 1;
    border: 2px solid rgb(204, 33, 33);
    padding: 0;
}

p {
    font-size: 30px;
    border: 2px solid rgb(204, 33, 33);
}
<div>
    <p>text</p>
    <p>text</p>
</div>
Sarkar
  • 1,225
  • 7
  • 21
0

Change p to span and alter CSS:

div {
       ...
       ...
       padding: 10px;
}

span {
      margin: 10px 0;
      ...
      ...
}

Or increase the div padding and remove span's margin, depending on the resulting UI that you need

Serge
  • 26
  • 3