How do I center the text vertically?

Within the confines of the rectangle upper part that it is in.

https://jsfiddle.net/1n8yxjus/1/

.hr3 {
  color: #38761d;
  font-style: normal;
  font-size: 100px;
  font-family: georgia;
  text-align: center;
  border-bottom: 6px solid #38761d;
  padding-bottom: 27px;
  margin-top: 3px;
  margin-bottom:-5px;
}

How can it be centred when you have 27px padding bottom on it?

Split the padding between the top and bottom.

  padding-bottom: 13px;
  padding-top:13px;

I didn’t want to move the green line.

There will only be a 1px difference so either add 1px to the top or bottom padding or add an extra 1px to your margin-top.

1 Like

Or take the giesswork out and use flex.

.hr3 {
  color: #38761d;
  font-style: normal;
  font-size: 100px;
  font-family: georgia;
  text-align: center;
  border-bottom: 6px solid #38761d;
  margin-top:0;
  margin-bottom:-5px;
  min-height:144px;
  display:flex;
  align-items:center;
  justify-content:center;
}
2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.