# Day 2 coding - cannot figure out how to center my buttons vertically

**URL:** <https://forum.freecodecamp.org/t/day-2-coding-cannot-figure-out-how-to-center-my-buttons-vertically/83521>\
**Category:** General\
**Created:** [February 3, 2017, 6:17pm UTC](https://forum.freecodecamp.org/t/day-2-coding-cannot-figure-out-how-to-center-my-buttons-vertically/83521 "2017-02-03T18:17:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rgebo21](https://avatars.discourse-cdn.com/v4/letter/r/c6cbf5/32.png) [@rgebo21](https://forum.freecodecamp.org/u/rgebo21)\
**Post date:** [February 3, 2017, 6:17pm UTC](https://forum.freecodecamp.org/t/day-2-coding-cannot-figure-out-how-to-center-my-buttons-vertically/83521/1 "2017-02-03T18:17:46Z")

</div>

Hi guys I’m working on the portfolio project and learning a lot. I just started freecodecamp and love it.

Can anyone take a look at my code and help me vertically align my buttons on the top?

> **[Portfolio](https://codepen.io/rgebo/pen/ygjJdy)**
>
> ...

Thanks so much

---

<div class="post-metadata">

**Author:** ![BartBucknill](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/bartbucknill/32/26852_2.png) [@BartBucknill](https://forum.freecodecamp.org/u/BartBucknill)\
**Post date:** [February 3, 2017, 6:25pm UTC](https://forum.freecodecamp.org/t/day-2-coding-cannot-figure-out-how-to-center-my-buttons-vertically/83521/2 "2017-02-03T18:25:23Z")

</div>

No solution but some suggestions:  
Here is a great summary of ways of centering things in CSS: [https://css-tricks.com/centering-css-complete-guide/](https://css-tricks.com/centering-css-complete-guide/)  
I would also highly recommend getting into flexbox later; that has solved a lot of my centering nightmares.

---

<div class="post-metadata">

**Author:** ![BartBucknill](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/bartbucknill/32/26852_2.png) [@BartBucknill](https://forum.freecodecamp.org/u/BartBucknill)\
**Post date:** [February 3, 2017, 6:42pm UTC](https://forum.freecodecamp.org/t/day-2-coding-cannot-figure-out-how-to-center-my-buttons-vertically/83521/3 "2017-02-03T18:42:19Z")

</div>

@rgebo21 I used flexbox to center the two buttons, you can see it here: [http://codepen.io/BartBucknill/pen/oBdPjo](http://codepen.io/BartBucknill/pen/oBdPjo)

I’m not that much further ahead than you, so not saying this is the best way to do it, but it is one way!

I also noticed that you have some CSS mixed in the HTML; its generally a lot easier to manage if you keep them separate - a file for HTML and a file for CSS.  
🙂

---

<div class="post-metadata">

**Author:** ![rgebo21](https://avatars.discourse-cdn.com/v4/letter/r/c6cbf5/32.png) [@rgebo21](https://forum.freecodecamp.org/u/rgebo21)\
**Post date:** [February 3, 2017, 6:46pm UTC](https://forum.freecodecamp.org/t/day-2-coding-cannot-figure-out-how-to-center-my-buttons-vertically/83521/4 "2017-02-03T18:46:51Z")

</div>

Wow awesome! Thanks so much I’m gonna have to look up what flex container is.

Yeah I’m actually not sure what css and html style’s difference is… I kinda noticed halfway through that they seem to function the same

---

<div class="post-metadata">

**Author:** ![BartBucknill](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/bartbucknill/32/26852_2.png) [@BartBucknill](https://forum.freecodecamp.org/u/BartBucknill)\
**Post date:** [February 3, 2017, 6:54pm UTC](https://forum.freecodecamp.org/t/day-2-coding-cannot-figure-out-how-to-center-my-buttons-vertically/83521/5 "2017-02-03T18:54:29Z")

</div>

When you put styling in your HTML doc inside `<style>` tags you are just writing CSS within the HTML doc; but it is easier to manage your code if you keep your css entirely separate from HTML (e.g. you wont use any `<style>` tags in your HTML). An example of why this is useful is that you might have multiple pages of HTML using the same CSS stylesheet - when you update it all the pages get updated.  
Sorry if you already realise this, I may have misinterpreted your last comment. The first FCC tutorials on HTML and CSS were a little confusing for me - I wasn’t quite sure what was CSS and what was HTML! 🙂  
I would definitely recommend checking out other resources, of which there are many; I used [https://www.udacity.com/course/intro-to-html-and-css--ud304](https://www.udacity.com/course/intro-to-html-and-css--ud304)

---

<div class="post-metadata">

**Author:** ![BartBucknill](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/bartbucknill/32/26852_2.png) [@BartBucknill](https://forum.freecodecamp.org/u/BartBucknill)\
**Post date:** [February 3, 2017, 6:57pm UTC](https://forum.freecodecamp.org/t/day-2-coding-cannot-figure-out-how-to-center-my-buttons-vertically/83521/6 "2017-02-03T18:57:59Z")

</div>

the flex-container is just a class that I defined. It also happens to be the term used in flexbox speak; the flex container is the parent and flex items are its children. A great reference for flexbox is here: [https://css-tricks.com/snippets/css/a-guide-to-flexbox/](https://css-tricks.com/snippets/css/a-guide-to-flexbox/)

---

<div class="post-metadata">

**Author:** ![rgebo21](https://avatars.discourse-cdn.com/v4/letter/r/c6cbf5/32.png) [@rgebo21](https://forum.freecodecamp.org/u/rgebo21)\
**Post date:** [February 3, 2017, 7:01pm UTC](https://forum.freecodecamp.org/t/day-2-coding-cannot-figure-out-how-to-center-my-buttons-vertically/83521/7 "2017-02-03T19:01:36Z")

</div>

Perfect! I didn’t understand the difference between CSS and HTML until you just explained it. I was confused because in the first tutorials they grouped them together so I understood that styling had to do with CSS, but didn’t really connect the dots. Thanks so much. I’m gonna read up more on flexbox

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 16, 2021, 5:12pm UTC](https://forum.freecodecamp.org/t/day-2-coding-cannot-figure-out-how-to-center-my-buttons-vertically/83521/8 "2021-01-16T17:12:29Z")

</div>

Closed on January 16, 2021, 5:12pm UTC


