Reputation: 17039
This is how the text looks at the moment
HTML:
<td style="vertical-align:middle;">
<img src="~/Images/Cancel.png" style="width:80px;height:80px" id="btnCancel" />
<span style="color:White;font-size:27px;font-weight:bold;">CANCEL</span>
</td>
How can I vertically align the text next to the image so it's in the middle?
Upvotes: 0
Views: 465
Reputation: 109
<td style="vertical-align:middle;">
<img src="~/Images/Cancel.png" style="width:80px;height:80px;float:left" id="btnCancel" />
<span style="color:White;font-size:27px;font-weight:bold;float:left; padding:24px 0 0 0">CANCEL</span>
</td>
Upvotes: 0
Reputation: 1226
If you make both the image and span display:inline-block you will be able to user vertical-align: middle.
<td style="vertical-align:middle;">
<img style="display: inline-block; vertical-align:middle; width:80px; height:80px" src="~/Images/Cancel.png" id="btnCancel" />
<span style="display: inline-block; vertical-align:middle; color: White; font-size: 27px; font-weight: bold;">CANCEL</span>
</td>
Upvotes: 0
Reputation: 99484
You could remove the vertical-align:middle;
from the table cell and apply that CSS declaration to both <img>
and the span>
element, as follows:
<td>
<img src="http://placehold.it/100" style="width:80px;height:80px;vertical-align:middle;" id="btnCancel" />
<span style="color:black;font-size:27px;font-weight:bold;vertical-align:middle;">CANCEL</span>
</td>
That's because the inline elements themselves are aligned in their baseline by default.
Upvotes: 2
Reputation: 4270
Try giving float:left
in css:
<img src="~/Images/Cancel.png" style="width:80px;height:80px; float:left" id="btnCancel" />
<span style="color:White;font-size:27px;font-weight:bold; float:left margin:5px 0 0 5px;">CANCEL</span>
Upvotes: 1