Question

I'm trying to create a table with 2 table data and 2 table headers. After researching about html codes, I realized the way to shift the word to the left is Text-Align="Left" as written below. Unfortunately, it didn't work. I'm not using any CSS but just plain html codes.

Here is my codes :

<table style="width: 100%;">
    <tr>
        <th style="width: 189px; height: 23px;">Full Name:</th>
        <td style="width: 1910px; height: 23px;">
            <asp:Label ID="lblFullName" runat="server" Text="" Text-Align="Left"></asp:Label>
        </td>
        <th style="width: 21px; height: 23px;">Contact:</th>
        <td style="width: 684px; height: 23px">
            <asp:Label ID="lblContact" runat="server" Text=""></asp:Label>
        </td>
    </tr>
</table>
Was it helpful?

Solution

<asp:Label /> will generate an <span> HTML tag, which is inline, and text-align to it is undefined, otherwise, set text-align of the td:

<td style="width: 1910px; height: 23px; text-align: center;">
    <asp:Label ID="lblFullName" runat="server" Text=""></asp:Label>
</td>

Or make your <asp:Label /> as a block element:

<asp:Label ID="lblFullName" runat="server" Text=""
    style="display: block; text-align: center;"
></asp:Label>

OTHER TIPS

Try this...

<table style="width: 100%;">
    <tr>
        <td style="width: 189px; height: 23px;">Full Name:</td>
        <td style="width: 1910px; height: 23px;">
            <asp:Label ID="lblFullName" runat="server" Text="" Text-Align="Left"></asp:Label>
        </td>
    </tr>
    <tr>
        <td style="width: 21px; height: 23px;">Contact:</td>
        <td style="width: 684px; height: 23px">
            <asp:Label ID="lblContact" runat="server" Text=""></asp:Label>
        </td>
</tr>
</table>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top