CSS Left Alignment Tables

I would like to align the table with CSS, similar to align = left in standard HTML, but I understand that this is a bad form. Is there any way to do this? If not, is there a way to format the left-aligned list of links next to the content without using tables?

+6
html css
source share
5 answers

For simplicity, extract material from style tags and use CSS classes instead:

<ul style="text-align: left; float: left;"> <li><a href="#">Your link here!</a></li> </ul> 

Simple When displaying the list, you need to specify the <ul> containing the element style overflow: auto; to remove the float for the next element that appears below it.

Further from jeroen he said: yes, the table should be aligned by default by default, if you did not set dir="rtl" somewhere in your DOM. And in this case, if you are not creative or you write Hebrew, there is no reason for his presence;)

+8
source share

We answer “how to align text inside a table?”, Not about divs or how to float them.

Here's how to make a table to the left of the page without using the deprecated align attribute:

 <table style="margin-right:auto;margin-left:0px"> 

Be sure to specify a width smaller than the table container, still large enough for your needs.

+7
source share

You can use an unordered list for links, put it in a div and put the div to the left. With the right left margin for the content, the list of links will move smoothly next to the content.

By the way, a table is usually left justified to begin with, but if you want to put it to the left of the content, you can also put it to the left.

+2
source share

As Jason noted, in HTML everything is aligned by default. If the contents of your table are not left-aligned, you have either changed their alignment in any way, or you will see a side effect from some addition or something else. To “fix” such a table, try CSS line by line:

 <style> TABLE, TBODY, TR, TD, TH { text-align:left; padding:0; border-spacing:0; /* or border-collapse:collapse */ } </style> 
+1
source share

use margin:auto 0
it's like a miracle

+1
source share

All Articles