You basically need text-align-last: justify , which indicates the justification for the "last text line" in the block element, this defaults to the standard direction, which is left in LTR.
<!DOCTYPE html> <html lang="en"> <head> <title>SO question 15994654</title> <style> #fields { width: 1000px; border: 1px solid gray; } .justified { text-align-last: justify; } </style> </head> <body> <p id="fields" class="justified"> <label for="input1">label1</label> <input id="input1" /> <label for="input2">label2</label> <input id="input2" /> <label for="input3">label3</label> <input id="input3" /> <label for="input4">label4</label> <input id="input4" /> <p> </body> </html>
This works in IE and Firefox (for older versions of Firefox add -moz-text-align-last: justify if necessary), however this fails in Webkit-based browsers (Chrome / Safari). To cover this browser, you need to replace .justified as follows so that the last line no longer appears as the "last line", so text-align: justify can do its job in the usual way:
.justified { text-align: justify; } .justified:after { content: ''; display: inline-block; width: 100%; }
Note that text-align-last: justify becomes redundant in this way.
Here's the jsfiddle demo .
source share