I would like to have some text vertically centered.
I am writing questions in the LMS Moodle and only have access to very basic HTML in a little text box to create the question, unfortunately I don’t know enough HTML. I don’t think I can use any CSS in this little textbox. At least, I don’t know how to. (Edit. I can use inline CSS styles, see answer below).
My end goal is to have some text next to a table with the text vertically centered with the height of the table. I couldn’t find the answer to this, hopefully it is not a duplicate. Any help is greatly appreciated. Thanks.
This is what I have so far:
<div>
<p style="float: left">A = </p>
<table style="float: left">
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
</tbody>
</table>
</div>
I am using style="float: left"
so that the text and the table appear next to each other.
2
Answers
If inline styles are okay to you, then you can use
display:flex
property on parentdiv
to arrange your components.I have use
height:100vh
which uses entire page height and center the child. You can adjust according to your needs.You can wrap your table inside another table.