Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Vertically aligning text in a border

I have a text div which I put a border around. I want the text to be in the middle of the border, however I don't want to use the padding-top attribute. How would I do that?

1 Answer

Jamie Reardon
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jamie Reardon
Treehouse Project Reviewer

If I understand correctly, you mean to have the content centred in a div with a border around it? If that's the case, why don't you just use flexbox?

div {
  display: flex;
  border: 2px solid #ccc;
}

.content {
  margin: auto;
}