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.
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
+ 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?
+ 2
Ipang if you want vertical alignment, set parent 100% height, display: flex, align-items:center
+ 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;
+ 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 : )
+ 1
thanks to both of you
0
left top