Here is a fiddle: http://jsfiddle.net/5s7vv/
What I want to do is have 2 buttons floated left and 2 right, just like the example, but button_4 should be the rightmost element. However, I cannot achieve that by just a simple float right. I should change their order in the markup, but that breaks user experience (tabbing between buttons is in wrong order), which actually leads to my question.
Is it possible to float both buttons right, in the correct order and still keep their tab index, and of course without extra markup. (wrapping them in div is easy, but I really want to avoid that).
I know the tabindex property, but as far as I know its not well supported...
HTML Code:
CSS:
#container{
width: 200px;
}
#container a{
width: 20px;
height: 20px;
}
.button_1, .button_2{
float: left;
}
.button_3, .button_4{
float: right;
}
.button_1{background-color: blue;}
.button_2{background-color: red;}
.button_3{background-color: green;}
.button_4{background-color: yellow;}
Use CSS property to set the height and width of div and use display property to place div in side-by-side format. float:left; This property is used for those elements(div) that will float on left side. float:right; This property is used for those elements(div) that will float on right side.
The clear property can be specified with any of the following values: none (default): Floating elements are allowed on both sides of the cleared element. left: No floating elements are allowed on the left side of the cleared element. right: No floating elements are allowed on the right side of the cleared element.
DIV elements are not compatible with tabindex in HTML4). The following elements support the tabindex attribute: A, AREA, BUTTON, INPUT, OBJECT, SELECT, and TEXTAREA. Essentially anything you would expect to be able to hold focus; form elements, links, etc.
It's a bit of a hack, but you could wrap buttons 3 and 4 in a div and right-float the div. That would keep the button order intact.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With