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

how to align a vertically div

I am unable to align the contents of a vertically div

2 Answers

Hi Yago,

Vertical alignment within a div is definitely one of the trickier positioning instances in CSS. Because you haven't included any specific context for the situation, it's hard to gauge how to address your specific problem, but I've included some resources below that will hopefully be of some help to you:

if you want to style the content of a div try to use margin-top or margin-bottom in your style.css example: yuo want to v-align some <h1>TEXT</h1> contained in your <div> element:

add in your style.css

div {
    margin:100px auto; <!-- it will add some 100px extra margin on the top and bottom of you div -->
}

h1 {
    margin:100px auto; <!-- it will add some 100px extra margin on the top and bottom of your h1 -->
}