What is the advantage of using float: right?

I have two divs on my site, one on the left and the other on the right side. But the client said don't use float:right . So I used margin:left What is the point of 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; } 
+4
source share
5 answers

I assume this is due to the markup order. Basically, you should write all your markup first, so it makes sense without any css, and then adds the css rules afterwards.

If you need to move the markup around to satisfy css terms, you can damage search engine optimization, accessibility, readability, and the clear structure of your code.

If you float something correctly, sometimes you need to first place the element in the markup, although it looks visually second.

This is, of course, speculation, and, as Marcus Aurelius wrote in his book meditations, a more or less waste of time is trying to understand another person (in this case your client), because you can never succeed, only fool so that you fully understand them and your motives. Instead, you should take care to make sure that your own motivations and actions are correct - so make sure you know when and when you are not swimming left or right (that you are now on the path to fulfillment), and reveal these truths to yours. customer.

+4
source

Actually, if you use float:left; in the second div, and the second div will begin immediately after the first div .

Like this: - http://tinkerbin.com/FfuvHZw4

And if you use float:right in the second div, and the second div will start on the right side of the parent div or body.

Like this: - http://tinkerbin.com/EgtjAJA1

+3
source

Well, nothing wrong with using float: right; Perhaps your client has an idea about this. May be a development issue.

+3
source

The only possible “plus” that I can think of not using float: right would be the fact that it calls inline elements that float on the right to appear in the reverse order (if the parent element is not floating, in which if his children appear in the correct order). So, if the contents (say, a list of elements) were pulled out of the database in a specific order, you need to reverse ORDER_BY so that they appear in the correct order. Similar to the order of simple HTML elements. They may not want to use float: right because they do not want to reorganize other code.

Fiddle: http://jsfiddle.net/nxdD4/1/

This is the only thing I can think of.

+3
source

After making sure that you will not look stupid, I will ask your client. Perhaps their cause has other consequences that you should be aware of, and perhaps Aurelius' reasoning may unnecessarily tie your hands, in the unlikely event that your client also does not think about ancient philosophy.

Most likely, the explanation I can think of is more easily updated if the code is in the same order as the render (although I would doubt that using the correct semantics in your CSS is more important), your code should appear on a page with a different code, or your code should be generated by CMS, whose setup / management is simpler, if everything in one sequence may have been selected from the context or in some useful forum, the respondent may have quoted less relevant sources. Roman emperors were never very good in touchy splendor.

0
source

All Articles