Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Center AND Right Align

In many weighty and serious tomes, particularly those published by the UK's venerable Her Majesty's Stationery Office (HMSO), one sees a great number of tables.

Often if the column contains numeric data, not only is it centred in the column, but also right aligned on that centre point, such that the last digit of the number is the entity that is centred. This layout is probably dictated by HMSO style rules.

I happen to have before me page 336 of History of the Second World War - United Kingdom Military Series - The War at Sea 1939-1945 - Volume I - The Defensive, and I find thereon a table matching the above description.

Using old-fashioned letterpress, or even in hot metal, it's admittedly totally manual and tedious, but relatively straightforward -- just use more or less leading until it lines up.

But I would like to know if it can it be done with Microsoft Word and/or HTML/CSS, preferably both.

like image 475
casgage Avatar asked Feb 01 '17 02:02

casgage


People also ask

How do you center align to the right?

Align a Paragraph To align left, press Ctrl + L. To align right, press Ctrl + R. To align center, press Ctrl + C. To justify, Ctrl + J.

What is left align and right align?

Left-aligned text is text that is aligned with a left edge. Right-aligned text is text that is aligned with a right edge. Centered text is text that is centered between two edges.


1 Answers

This can be accomplished in HTML/CSS by wrapping the text with a centered inline-block element:

.wrap {
  text-align:right;
  border: 3px dotted blue;  
  display: inline-block;
}
.container {
  border: 10px solid red;
  text-align: center;
}
<div class="container">
  <div class="wrap">
    Line 1 asddsa<br>
    Line 2 asdasdf<br>
    Line 3 asdfasdfasdf<br>
    Line 4 dsdf<br>
    Line 5<br>
    Line 6 s
  </div>
</div>
like image 137
Mike Avatar answered Sep 30 '22 05:09

Mike