Reputation: 9542
I have two divs in my website,one is left side and other is right side.
But client said don't use float:right
.So i used margin:left
What is the plus point of not using float:right
? margin-left
or float:right
,
or am I wrong? Please help me.
#left
{
float:left;
width:200px;
}
#right
{
float:right;
width:200px;
}
or
#left
{
float:left;
width:200px;
}
#right
{
margin-left:250px;
width:200px;
}
Upvotes: 4
Views: 224
Reputation: 6382
Having ascertained that you will not look stupid for asking, I'd ask your client. Perhaps their reason has other implications you should be aware of, and perhaps Aurelius's reasoning might tie your hands unnecessarily, in the unlikely event that your client is not also thinking in terms of ancient philosophy.
Most likely explanation I can think of is code is more easily updated if the code is in the same order as it is rendered, (although I'd counter that using the correct semantics in your CSS is more important), your code is to appear in a page with other code, or your code is to be generated by a CMS, whose setup/management is simpler if things is in the same sequence, could have been picked up out of context, or some well-meaning forum respondent maybe cited less than relevant sources to them. The Roman emperors never were much good at the touchy feely.
Upvotes: 0
Reputation: 58531
I imagine it is to do with the order of the markup. In principle, you should write all your markup first, so it makes sense without any css, and then add css rules afterwards.
If you need to move your markup around to satisfy the css conditions, you might be damaging the search-engine-optimisation, accessibility, or readability and clear structure of your code.
If you float something right, sometimes you need to put the element first in the markup, even though it appears visually second.
This is of course speculation, and as Marcus Aurelius wrote about in his book meditations - it is more or less a waste of time trying to understand another person (in this case your client) as you can never truly succeed, only fool yourself into thinking you fully understand them and their motivations. Instead, you should concern yourself with making sure your own motivations, and actions are correct - so make sure you know when and when not ot float things left or right (which you are on the path to doing now), and reveal these truths to your client.
Upvotes: 4
Reputation: 5104
The only possible "plus" I can think of to not using float: right
would be the fact that it causes inline elements that are floated right to appear in reverse order (unless the parent element is the one being floated, in which case its children will appear in the correct order). So, if the content (say a list of items) is pulled from the database in a specific order, the ORDER_BY
would need to be reversed to get them to appear in the desired order. Likewise with the order of plain HTML elements. They may not want you to use float: right
because they don't want to have to refactor other code.
Fiddle: http://jsfiddle.net/nxdD4/1/
That's about the only thing I can think of.
Upvotes: 3
Reputation: 1858
Well, nothing wrong using float:right; Maybe your client have an idea about that. Could be a development issue.
Upvotes: 3
Reputation: 7778
Actually if you use float:left;
in the second div than the second div will start after first div immediately.
Like this :- http://tinkerbin.com/FfuvHZw4
And if you use float:right
in the second div than the second div will start after from the right side of the parent div or body.
Like this :- http://tinkerbin.com/EgtjAJA1
Upvotes: 3