I would like to center a block of left-aligned text within a div, ensuring that the visual width of the text block is centered rather than the block itself.
In situations where the div is narrow and the text is too long to fit on one line, causing it to overflow, this discrepancy becomes apparent.
Although I have displayed the text block as light blue for demonstration purposes in the examples below, in reality they will match the color of the parent div (white) with no line breaks.
In scenario 1a, the text fits within one line and is smaller than the maximum width of the text block, allowing me to set the width of the text block accordingly without any issues.
In case 2a, however, the text exceeds the maximum width and wraps onto the next line. This results in the visible text block appearing off-center.
How can I achieve both scenarios shown as 1b and 2b only using HTML and CSS?
Edit 1: Despite several suggestions on how to replicate the situation in 1a and 2a, my focus lies on accomplishing the layout seen in 1b and 2b.
Edit 2: The code I'm utilizing closely resembles David's example link (http://jsfiddle.net/davidThomas/28aef/). The use of text area colors is purely illustrative; changing it to white (http://jsfiddle.net/28aef/2/) highlights the issue where the margins are unequal.