0

Can we make a table in the middle of the page? If yes then how!!

i try align attribute but it is not working.

28th Oct 2018, 5:53 AM
Md Shoaib
Md Shoaib - avatar
7 Answers
+ 3
You can try to wrap the table element within a div element having its align attribute set to "center". But pay attention this will put the div (along with the table within) at center horizontally, for vertical alignment it can be tricky (read: "I don't know" : ) <div align="center"> <table> <tr><td>Row 1 Col 1</td><td>Row 1 Col 2</td></tr> <tr><td>Row 2 Col 1</td><td>Row 2 Col 2</td></tr> <tr><td>Row 3 Col 1</td><td>Row 3 Col 2</td></tr> </table> </div> Hth, cmiiw
28th Oct 2018, 8:47 AM
Ipang
+ 3
╰☆☆ S͎p͎e͎a͎r͎y͎ ☆☆╼ Thanks, but is that the CSS for the table or the container div? and what's 100% height?
28th Oct 2018, 8:54 AM
Ipang
+ 2
Ipang if you want vertical alignment, set parent 100% height, display: flex, align-items:center
28th Oct 2018, 8:51 AM
Gordon
Gordon - avatar
+ 2
https://code.sololearn.com/WMT0u4UcG2FR/?ref=app Ipang yes CSS, like this: 1. if no other content, the parent can be body. otherwise like you said use a div container. 2. height: 100vh (height of viewpoint) for the parent 3. display:flex affects the position of children 4. justify-content: center makes all children align at horizontal center. 5. align-items : center makes all children align at vertical center. this is flexbox, taught by Domino (👈follow her) another method is not apply css on parent, but apply css on children: position: absolute; top: ___px; left:___px;
28th Oct 2018, 8:59 AM
Gordon
Gordon - avatar
+ 2
Wow ╰☆☆ S͎p͎e͎a͎r͎y͎ ☆☆╼ Thanks again, didn't expect that much coming, and with a code too, cool ... Alright, I'll look into it, this flex thingy is something after all, I'm kinda outdated when it comes to web tech, so Thanks for showing this ideas : )
28th Oct 2018, 9:04 AM
Ipang
+ 1
thanks to both of you
28th Oct 2018, 12:31 PM
Md Shoaib
Md Shoaib - avatar
0
left top
28th Oct 2018, 7:50 AM
Gordon
Gordon - avatar