I want to display a company logo and a company name right next to it. This is what i tried to do. This code will run in old browsers that does not support flexbox so I need to do this in simple HTML and CSS. This is what I tried to write:
.logo {
transform: translateX(2em);
}
.name1 {
font-size: 25px;
color: #e9c46a;
}
.name2 {
font-size: 25px;
color: white;
}
<table style="background-color: cadetblue;width:100%;padding:10px">
<tr>
<td rowspan="3" width="130">
<img src="Images/facebook.png" height="80" width="80" class="logo" />
</td>
</tr>
<tr>
<td class="name1">This is some text</td>
</tr>
<tr>
<td class="name2">This is some text1</td>
</tr>
</table>
This is how the screen shot looks like:
is their any way, I can reduce the space between "This is some text" and "This is some text1". I don’t want to use flexbox because I am using this code on older device. I am not very good with CSS. I can use float if anyone can help me with using float. Below are the styles that I am using:
any help will be appreciated.
2
Answers
Vertically aligning the texts to bring them closer with
valign
attribute and also removing the padding of the table cells removes more space. I hope that’s close enough.There’s a couple of ways to bring your text content closer togheter.
You probably want to apply a combination of
border-collapse
andvertical-align
rules.I’ve applied a white border to the table cells so that it becomes apparent how the rule effects your output.
The
border-collapse
will remove spacing between the cells.The
vertical-align
will attach the text to the bottom/top of the cell.The image itself will cause the text cell to take up more space.
If different vertical aligns are not feasible, you might want to decrease the image size.
The text inside the cell uses
line-height
to determine how much vertical space to take up, reducing that either via percentage or viapx
value will bring the lines even closer togheter.