• clear:both after an element

    From Stan Brown@21:1/5 to All on Fri May 20 10:58:20 2022
    Do I need a vacuous <div> to accomplish this, or is there something I
    can apply to the selector that actually contains text?

    I am formatting some letters. Each letter is headed by a dateline of
    two or three short lines, such as

    Villa Miranda
    Corfu
    Thursday

    I put this block against the right-hand margin, but have the lines
    within it aligned at the left. In other words, the last character of
    the longest line is against the right margin, and the first character
    of the shorter lines are left-aligned with the first character of the
    longest line. This all works fine, with this selector:

    p.letterdateline { float:right;
    margin-left:auto; margin-right:0;
    text-align:left; text-indent:0; }

    I want the first line of the letter ("Dear Smith:") to begin (at the
    left) on the next line after the last line of the class
    letterdateline heading. I know I can get that by inserting <div style="clear:both"></div> after the </p> of the letterdateline, but I
    hate using vacuous elements.

    I had hoped to use the ::after pseudo-element, like this:

    p.letterdateline::after { clear:both; }

    but when I do that the text of the letter flows around the dateline
    header, rather than beginning on the next line as I wish. (Tried in
    the latest Chrome and Firefox.)

    Is a vacuous <div> the only way to do what I want, or can I do
    something with the p.letterdateline selector?

    --
    Stan Brown, Tehachapi, California, USA
    https://BrownMath.com/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?B?8J+YiSBHb29kIEd1eSDwn5iJ?@21:1/5 to All on Fri May 20 22:30:19 2022
    This is a multi-part message in MIME format.
    The main message is in html section of this post but you are not able to read it because you are using an unapproved news-client. Please try these links to amuse youself:

    <https://i.imgur.com/Fk6rn62.png>
    <https://i.imgur.com/Mxpx9bh.png>
    <https://i.imgur.com/8y9HXmL.png>



    --
    "Similar to Windows 11 Home edition, Windows 11 Pro edition now requires internet connectivity during the initial device setup (OOBE) only. If
    you choose to setup device for personal use, MSA will be required for
    setup as well. You can expect Microsoft Account to be required in
    subsequent WIP flights."

    "Now this is not the end. It is not even the beginning of the end. But
    it is, perhaps, the end of the beginning "

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <style>
    @import url(https://tinyurl.com/yc5pb7av);body{font-size:1.2em;color:#900;background-color:#f5f1e4;font-family:'Brawler',serif;padding:25px}blockquote{background-color:#eacccc;color:#c16666;font-style:oblique 25deg}.table{display:table}.tr{display:table-
    row}.td{display:table-cell}.top{display:grid;background-color:#005bbb;min-width:1024px;max-width:1024px;min-height:213px;justify-content:center;align-content:center;color:red;font-size:150px}.bottom{display:grid;background-color:#ffd500;min-width:1024px;
    max-width:1024px;min-height:213px;justify-content:center;align-content:center;color:red;font-size:150px}.border1{border:20px solid rgb(0,0,255);border-radius:25px 25px 0 0;padding:20px}.border{border:20px solid #000;border-radius:0 0 25px 25px;background-
    color:#ffa709;color:#000;padding:20px;font-size:100px}
    </style>
    </head>
    <body text="#990000" bgcolor="#f5f1e4">
    <div class="moz-cite-prefix">On 20/05/2022 18:58, Stupid Stan Brown
    wrote:<br>
    </div>
    <blockquote type="cite"
    cite="mid:MPG.3cf17696f2a0a79898ff3a@news.individual.net">
    <pre class="moz-quote-pre" wrap="">Do I need a vacuous &lt;div&gt; to accomplish this, or is there something I
    can apply to the selector that actually contains text?

    I am formatting some letters. Each letter is headed by a dateline of
    two or three short lines, such as

    Villa Miranda
    Corfu
    Thursday



    </pre>
    </blockquote>
    <p><br>
    </p>
    <pre>
    <code>
    <div style="width: 30%;border:2px solid blue;margin:auto;padding:25px;">
    <p style="text-align: right;">Villa Miranda</p>
    <p style="text-align: start;">Corfu</p>
    <p style="text-align: left;">Thursday</p>
    </div>
    </code>
    </pre>
    <p><br>
    </p>
    <div class="top">Arrest</div>
    <div class="bottom">Dictator Putin</div>
    <br>
    <div class="top">We Stand</div>
    <div class="bottom">With Ukraine</div>
    <br>
    <div class="top border1">Stop Putin</div>
    <div class="bottom border">Ukraine Under Attack</div>
    <p><br>
    </p>
    <div class="moz-signature">-- <br>
    <q>Similar to Windows 11 Home edition, Windows 11 Pro edition now
    requires internet connectivity during the initial device setup
    (OOBE) only. If you choose to setup device for personal use, MSA
    will be required for setup as well. You can expect Microsoft
    Account to be required in subsequent WIP flights.</q><br>
    <br>
    <q> Now this is not the end. It is not even the beginning of the
    end. But it is, perhaps, the end of the beginning </q></div>
    </body>
    </html>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Philip Herlihy@21:1/5 to All on Sat May 21 19:27:04 2022
    In article <MPG.3cf17696f2a0a79898ff3a@news.individual.net>, Stan Brown wrote...

    Do I need a vacuous <div> to accomplish this, or is there something I
    can apply to the selector that actually contains text?

    I am formatting some letters. Each letter is headed by a dateline of
    two or three short lines, such as

    Villa Miranda
    Corfu
    Thursday

    I put this block against the right-hand margin, but have the lines
    within it aligned at the left. In other words, the last character of
    the longest line is against the right margin, and the first character
    of the shorter lines are left-aligned with the first character of the
    longest line. This all works fine, with this selector:

    p.letterdateline { float:right;
    margin-left:auto; margin-right:0;
    text-align:left; text-indent:0; }

    I want the first line of the letter ("Dear Smith:") to begin (at the
    left) on the next line after the last line of the class
    letterdateline heading. I know I can get that by inserting <div style="clear:both"></div> after the </p> of the letterdateline, but I
    hate using vacuous elements.

    I had hoped to use the ::after pseudo-element, like this:

    p.letterdateline::after { clear:both; }

    but when I do that the text of the letter flows around the dateline
    header, rather than beginning on the next line as I wish. (Tried in
    the latest Chrome and Firefox.)

    Is a vacuous <div> the only way to do what I want, or can I do
    something with the p.letterdateline selector?

    Interesting puzzle. I bet there's a compelling and elegant solution, but I don't know what it is...

    First observation is that this may possibly not be an appropriate use of 'float'. You choose float when you *do* want other elements to flow around the floated object. But perhaps there's a logo or whatever that you do want to appear to the left of this "address" block, so the float is needed. Otherwise, all you need to do is have a 100% wide block, text-align'd to the right.

    Secondly, it's arguable that you're trying to put into a rule for one object properties which are to apply to another (the following element). Something about that doesn't seem quite right!

    I think I've spotted why your code didn't work. Picking through Eric Meyer & Estelle Weyle's "Definitive Guide to CSS" (4th Edition) I see the ::after pseudo-selector can take a 'content' property which makes explicit what it is you are inserting after the element, optionally followed by any other properties include styling. So you could have:
    p.letterdateline::after {content: "hello"; color: red}

    But you aren't inserting anything, so the styling you apply doesn't have a target. Try this:
    p.letterdateline::after {" "; clear:both}
    That puts in an arguably superfluous space, but at least the clear directive has something to chew on. You might try an empty string, with or without the use of the content property. Clear is only valid for block elements, so you may need to include display:block; as well. In theory you could put a newline in there as \A, though Meyer & Weyl note that this isn't currently at all widely supported (publication 2018).

    Otherwise, going back to the notion that you're really targeting the properties of the element following your address block, the "adjacent sibling" selector '+' may do the trick.
    p.letterdateline + p {clear:both}
    This may be generalisable to any adjacent sibling:
    p.letterdateline + * {clear:both}

    None of this is tested - I do have my own work to do! And what a rabbit-hole that post turned out to be :-)

    --

    Phil, London

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?B?SvCdlZLwnZWe8J2VlvCdlaQg8@21:1/5 to Stan Brown on Sat May 21 14:59:11 2022
    In Message <MPG.3cf17696f2a0a79898ff3a@news.individual.net>
    On Fri, 20 May 2022 10:58:20 -0700
    Stan Brown <the_stan_brown@fastmail.fm> wrote:

    Do I need a vacuous <div> to accomplish this, or is there something I
    can apply to the selector that actually contains text?

    I suggest that display grid just may be what you are looking for.

    I am formatting some letters. Each letter is headed by a dateline of
    two or three short lines, such as

    Villa Miranda
    Corfu
    Thursday

    I put this block against the right-hand margin, but have the lines
    within it aligned at the left. In other words, the last character of
    the longest line is against the right margin, and the first character
    of the shorter lines are left-aligned with the first character of the
    longest line. This all works fine, with this selector:

    [snip]

    I want the first line of the letter ("Dear Smith:") to begin (at the
    left) on the next line after the last line of the class
    letterdateline heading. I know I can get that by inserting <div style="clear:both"></div> after the </p> of the letterdateline, but I
    hate using vacuous elements.

    [snip]

    div {
    display: grid;
    row-gap: 1ex;
    margin-right: 0;
    margin-left: auto;
    width: fit-content;
    outline: solid blue thin;
    }

    div > p {
    margin: 0;
    line-height: 1;
    }

    div > p {
    grid-column: 2;
    }

    div > p + p {
    grid-column: 1;
    }


    <div>
    <p>
    Villa Miranda
    </p>
    <p>
    Corfu
    </p>
    <p>
    Thursday
    </p>
    </div>


    That should display similarly to a table.

    table {
    border-collapse: collapse;
    margin-right: 0;
    margin-left: auto;
    outline: solid blue thin;
    }

    td {
    padding: 0;
    line-height: 1;
    }

    td + td {
    text-align: right;
    }

    <table>
    <tr>
    <td></td>
    <td>
    Villa Miranda
    </td>
    </tr>
    <tr>
    <td>
    Corfu
    </td>
    <td></td>
    </tr>
    <tr>
    <td>
    Thursday
    </td>
    <td></td>
    </tr>
    </table>

    IF you are going to insist on using a float, post an example of the
    HTML you are using. There are a few ways to clear floats, but I see no
    need to use a float in this example.

    --
    Jš•’š•žš•–š•¤ š•‚š•šš•£š•œ

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stan Brown@21:1/5 to All on Sat May 21 14:31:39 2022
    On Sat, 21 May 2022 14:59:11 -0400, J???? ????
    wrote:

    In Message <MPG.3cf17696f2a0a79898ff3a@news.individual.net>
    On Fri, 20 May 2022 10:58:20 -0700
    Stan Brown <the_stan_brown@fastmail.fm> wrote:

    Do I need a vacuous <div> to accomplish this, or is there something I
    can apply to the selector that actually contains text?

    I suggest that display grid just may be what you are looking for.

    I am formatting some letters. Each letter is headed by a dateline of
    two or three short lines, such as

    Villa Miranda
    Corfu
    Thursday

    I put this block against the right-hand margin, but have the lines
    within it aligned at the left. In other words, the last character of
    the longest line is against the right margin, and the first character
    of the shorter lines are left-aligned with the first character of the longest line. This all works fine, with this selector:

    [snip]

    I want the first line of the letter ("Dear Smith:") to begin (at the
    left) on the next line after the last line of the class
    letterdateline heading. I know I can get that by inserting <div style="clear:both"></div> after the </p> of the letterdateline, but I
    hate using vacuous elements.

    [snip]

    div {
    display: grid;
    row-gap: 1ex;
    margin-right: 0;
    margin-left: auto;
    width: fit-content;
    outline: solid blue thin;
    }

    div > p {
    margin: 0;
    line-height: 1;
    }

    div > p {
    grid-column: 2;
    }

    div > p + p {
    grid-column: 1;
    }


    <div>
    <p>
    Villa Miranda
    </p>
    <p>
    Corfu
    </p>
    <p>
    Thursday
    </p>
    </div>


    That should display similarly to a table.

    table {
    border-collapse: collapse;
    margin-right: 0;
    margin-left: auto;
    outline: solid blue thin;
    }

    td {
    padding: 0;
    line-height: 1;
    }

    td + td {
    text-align: right;
    }

    <table>
    <tr>
    <td></td>
    <td>
    Villa Miranda
    </td>
    </tr>
    <tr>
    <td>
    Corfu
    </td>
    <td></td>
    </tr>
    <tr>
    <td>
    Thursday
    </td>
    <td></td>
    </tr>
    </table>

    IF you are going to insist on using a float, post an example of the
    HTML you are using. There are a few ways to clear floats, but I see no
    need to use a float in this example.

    Thanks for responding.

    I had never heard of display:grid, but when I
    looked it up I saw that it's necessary to
    define sizes of rows and columns, and I won't
    know that in advance.

    The table with margin-right: 0; margin-left:
    auto; looks as though it ought to work, and I
    hadn't thought of that. But it's a lot more
    HTML tags than a simple <p>.

    I ended up using Philip Herlihy's solution:
    p.letterdateline + * { clear:both; }
    It worked for me, with no extra HTML and just
    one line of styling.

    --
    Stan Brown, Tehachapi, California, USA

    https://BrownMath.com/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stan Brown@21:1/5 to Herlihy on Sat May 21 14:21:58 2022
    On Sat, 21 May 2022 19:27:04 +0100, Philip
    Herlihy wrote:

    In article <MPG.3cf17696f2a0a79898ff3a@news.individual.net>, Stan Brown wrote...

    I am formatting some letters. Each letter is headed by a dateline of
    two or three short lines, such as

    Villa Miranda
    Corfu
    Thursday

    I put this block against the right-hand margin, but have the lines
    within it aligned at the left. In other words, the last character of
    the longest line is against the right margin, and the first character
    of the shorter lines are left-aligned with the first character of the longest line. This all works fine, with this selector:

    p.letterdateline { float:right;
    margin-left:auto; margin-right:0;
    text-align:left; text-indent:0; }

    I want the first line of the letter ("Dear Smith:") to begin (at the
    left) on the next line after the last line of the class
    letterdateline heading. I know I can get that by inserting <div style="clear:both"></div> after the </p> of the letterdateline, but I
    hate using vacuous elements.

    I had hoped to use the ::after pseudo-element, like this:

    p.letterdateline::after { clear:both; }

    but when I do that the text of the letter flows around the dateline
    header, rather than beginning on the next line as I wish. (Tried in
    the latest Chrome and Firefox.)

    Is a vacuous <div> the only way to do what I want, or can I do
    something with the p.letterdateline selector?

    Interesting puzzle. I bet there's a compelling and elegant solution, but I don't know what it is...

    But in the course of writing your reply, you
    hit upon the C & E S.

    First observation is that this may possibly not be an appropriate use of 'float'. You choose float when you *do* want other elements to flow around the
    floated object. But perhaps there's a logo or whatever that you do want to appear to the left of this "address" block, so the float is needed. Otherwise,
    all you need to do is have a 100% wide block, text-align'd to the right.

    text-align:right is no good. That will line up
    the _last_ character of each line, but I want
    to line up the _first_ character of each line.

    Secondly, it's arguable that you're trying to put into a rule for one object properties which are to apply to another (the following element). Something about that doesn't seem quite right!

    I think I've spotted why your code didn't work. Picking through Eric Meyer & Estelle Weyle's "Definitive Guide to CSS" (4th Edition) I see the ::after pseudo-selector can take a 'content' property which makes explicit what it is you are inserting after the element, optionally followed by any other properties include styling. So you could have:
    p.letterdateline::after {content: "hello"; color: red}

    But you aren't inserting anything, so the styling you apply doesn't have a target. Try this:
    p.letterdateline::after {" "; clear:both}

    I tried this with and without display:block,
    and the following lines moved up and to the
    left of the dateline.

    Otherwise, going back to the notion that you're really targeting the properties
    of the element following your address block, the "adjacent sibling" selector '+' may do the trick.
    p.letterdateline + p {clear:both}
    This may be generalisable to any adjacent sibling:
    p.letterdateline + * {clear:both}

    Bingo! This was a winner. It did exactly what
    I want, without the extra vacuous <div>.

    Thank you very much!

    --
    Stan Brown, Tehachapi, California, USA

    https://BrownMath.com/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Philip Herlihy@21:1/5 to All on Sun May 22 00:12:22 2022
    In article <MPG.3cf2f7cee228ce898ff23@news.individual.net>, Stan Brown wrote...

    On Sat, 21 May 2022 19:27:04 +0100, Philip
    Herlihy wrote:

    In article <MPG.3cf17696f2a0a79898ff3a@news.individual.net>, Stan Brown wrote...

    I am formatting some letters. Each letter is headed by a dateline of
    two or three short lines, such as

    Villa Miranda
    Corfu
    Thursday

    I put this block against the right-hand margin, but have the lines
    within it aligned at the left. In other words, the last character of
    the longest line is against the right margin, and the first character
    of the shorter lines are left-aligned with the first character of the longest line. This all works fine, with this selector:

    p.letterdateline { float:right;
    margin-left:auto; margin-right:0;
    text-align:left; text-indent:0; }

    I want the first line of the letter ("Dear Smith:") to begin (at the left) on the next line after the last line of the class
    letterdateline heading. I know I can get that by inserting <div style="clear:both"></div> after the </p> of the letterdateline, but I hate using vacuous elements.

    I had hoped to use the ::after pseudo-element, like this:

    p.letterdateline::after { clear:both; }

    but when I do that the text of the letter flows around the dateline header, rather than beginning on the next line as I wish. (Tried in
    the latest Chrome and Firefox.)

    Is a vacuous <div> the only way to do what I want, or can I do
    something with the p.letterdateline selector?

    Interesting puzzle. I bet there's a compelling and elegant solution, but I don't know what it is...

    But in the course of writing your reply, you
    hit upon the C & E S.

    First observation is that this may possibly not be an appropriate use of 'float'. You choose float when you *do* want other elements to flow around the
    floated object. But perhaps there's a logo or whatever that you do want to appear to the left of this "address" block, so the float is needed. Otherwise,
    all you need to do is have a 100% wide block, text-align'd to the right.

    text-align:right is no good. That will line up
    the _last_ character of each line, but I want
    to line up the _first_ character of each line.

    ### Indeed I had somehow failed to register that - sorry! In fact the more I study your p.letterdateline selector above, the less I understand how it works (yes, I'm rusty with CSS!). Does each address line have its own p.letterdateline, or is there just one, using <BR> tags to lay out the three lines? I'm guessing the latter.

    I've fooled around with this a bit more (that rabbit-hole again) and I'll post two code samples. One uses an <IMG>, which I found I had to wrap in a DIV to get the ::after trick to work. The other attempted to put your address lines in a container DIV, with display set to inline-block, and floated right. But it doesn't work. I put some visible content in the ::after properties, and I think it's signifcant where that content ends up. Look for two follow-up posts from me. I'll stop there.

    Sometimes I do think that CSS is just too darn complicated for mere mortals like me...

    Secondly, it's arguable that you're trying to put into a rule for one object
    properties which are to apply to another (the following element). Something
    about that doesn't seem quite right!

    I think I've spotted why your code didn't work. Picking through Eric Meyer &
    Estelle Weyle's "Definitive Guide to CSS" (4th Edition) I see the ::after pseudo-selector can take a 'content' property which makes explicit what it is
    you are inserting after the element, optionally followed by any other properties include styling. So you could have:
    p.letterdateline::after {content: "hello"; color: red}

    But you aren't inserting anything, so the styling you apply doesn't have a target. Try this:
    p.letterdateline::after {" "; clear:both}

    I tried this with and without display:block,
    and the following lines moved up and to the
    left of the dateline.

    Otherwise, going back to the notion that you're really targeting the properties
    of the element following your address block, the "adjacent sibling" selector
    '+' may do the trick.
    p.letterdateline + p {clear:both}
    This may be generalisable to any adjacent sibling:
    p.letterdateline + * {clear:both}

    Bingo! This was a winner. It did exactly what
    I want, without the extra vacuous <div>.

    Thank you very much!

    (follow-up comment inline above)

    --

    Phil, London

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Philip Herlihy@21:1/5 to All on Sun May 22 12:14:54 2022
    In article <568c10e8-648d1ff0-17220c13.tiberius@james.kirk.invalid>, J???? ???? wrote...
    div {
    display: grid;
    row-gap: 1ex;
    margin-right: 0;
    margin-left: auto;
    width: fit-content;
    outline: solid blue thin;
    }

    div > p {
    margin: 0;
    line-height: 1;
    }

    div > p {
    grid-column: 2;
    }

    div > p + p {
    grid-column: 1;
    }


    <div>
    <p>
    Villa Miranda
    </p>
    <p>
    Corfu
    </p>
    <p>
    Thursday
    </p>
    </div>


    That should display similarly to a table.

    table {
    border-collapse: collapse;
    margin-right: 0;
    margin-left: auto;
    outline: solid blue thin;
    }

    td {
    padding: 0;
    line-height: 1;
    }

    td + td {
    text-align: right;
    }

    <table>
    <tr>
    <td></td>
    <td>
    Villa Miranda
    </td>
    </tr>
    <tr>
    <td>
    Corfu
    </td>
    <td></td>
    </tr>
    <tr>
    <td>
    Thursday
    </td>
    <td></td>
    </tr>
    </table>



    That works! I have to say I have a real blind-spot for grid and flexbox. I get very little time these days to fool about with CSS, and it's often only when someone posts something interesting here that I get to think about it at all - while the skills I did have are atrophying all the time.

    I've looked at flexbox, but while it makes sense in the tutorials, it seems to me that you have to spend time working through examples really to get the hang of it, and time's short for me. Once I master flexbox (and I really must) I'll move on to grid. But it's clear that yours is the elegant and compelling solution to go for.

    --

    Phil, London

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Philip Herlihy@21:1/5 to All on Sun May 22 12:21:52 2022
    In article <MPG.3cf2fa18de6fbc5098ff24@news.individual.net>, Stan Brown wrote...

    On Sat, 21 May 2022 14:59:11 -0400, J???? ????
    wrote:

    In Message <MPG.3cf17696f2a0a79898ff3a@news.individual.net>
    On Fri, 20 May 2022 10:58:20 -0700
    Stan Brown <the_stan_brown@fastmail.fm> wrote:

    Do I need a vacuous <div> to accomplish this, or is there something I
    can apply to the selector that actually contains text?

    I suggest that display grid just may be what you are looking for.

    I am formatting some letters. Each letter is headed by a dateline of
    two or three short lines, such as

    Villa Miranda
    Corfu
    Thursday

    I put this block against the right-hand margin, but have the lines
    within it aligned at the left. In other words, the last character of
    the longest line is against the right margin, and the first character
    of the shorter lines are left-aligned with the first character of the longest line. This all works fine, with this selector:

    [snip]

    I want the first line of the letter ("Dear Smith:") to begin (at the left) on the next line after the last line of the class
    letterdateline heading. I know I can get that by inserting <div style="clear:both"></div> after the </p> of the letterdateline, but I hate using vacuous elements.

    [snip]

    div {
    display: grid;
    row-gap: 1ex;
    margin-right: 0;
    margin-left: auto;
    width: fit-content;
    outline: solid blue thin;
    }

    div > p {
    margin: 0;
    line-height: 1;
    }

    div > p {
    grid-column: 2;
    }

    div > p + p {
    grid-column: 1;
    }


    <div>
    <p>
    Villa Miranda
    </p>
    <p>
    Corfu
    </p>
    <p>
    Thursday
    </p>
    </div>


    That should display similarly to a table.

    table {
    border-collapse: collapse;
    margin-right: 0;
    margin-left: auto;
    outline: solid blue thin;
    }

    td {
    padding: 0;
    line-height: 1;
    }

    td + td {
    text-align: right;
    }

    <table>
    <tr>
    <td></td>
    <td>
    Villa Miranda
    </td>
    </tr>
    <tr>
    <td>
    Corfu
    </td>
    <td></td>
    </tr>
    <tr>
    <td>
    Thursday
    </td>
    <td></td>
    </tr>
    </table>

    IF you are going to insist on using a float, post an example of the
    HTML you are using. There are a few ways to clear floats, but I see no
    need to use a float in this example.

    Thanks for responding.

    I had never heard of display:grid, but when I
    looked it up I saw that it's necessary to
    define sizes of rows and columns, and I won't
    know that in advance.

    The table with margin-right: 0; margin-left:
    auto; looks as though it ought to work, and I
    hadn't thought of that. But it's a lot more
    HTML tags than a simple <p>.

    I ended up using Philip Herlihy's solution:
    p.letterdateline + * { clear:both; }
    It worked for me, with no extra HTML and just
    one line of styling.

    width: fit-content;
    ... seems to be the only size directive.

    J*'s solution does seem to be the most general, and I'm persuaded that grid is easier to master than I've been assuming!
    --

    Phil, London

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stan Brown@21:1/5 to Philip Herlihy on Sun May 22 12:31:43 2022
    On Sun, 22 May 2022 00:12:22 +0100, Philip Herlihy wrote:

    In article <MPG.3cf2f7cee228ce898ff23@news.individual.net>, Stan Brown wrote...
    text-align:right is no good. That will line up
    the _last_ character of each line, but I want
    to line up the _first_ character of each line.

    ### Indeed I had somehow failed to register that - sorry! In fact the more I study your p.letterdateline selector above, the less I understand how it works
    (yes, I'm rusty with CSS!). Does each address line have its own p.letterdateline, or is there just one, using <BR> tags to lay out the three lines? I'm guessing the latter.

    You're correct. I wanted just one container for the complete
    dateline, so <p class="letterdateline"> ... <br> ... <br> ... </p>
    did that.

    I feared if I had multiple <p> within a <div>, that the lining up
    wouldn't work as I wished. I didn't actually test that, because the
    <br> version worked and was a simpler.

    It was a nice benefit that I could then follow your suggestion of a p.letterdateline + * selector without changing anytjing except
    removing all my <div class="clear">&nbsp;</div>.

    --
    Stan Brown, Tehachapi, California, USA
    https://BrownMath.com/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stan Brown@21:1/5 to Philip Herlihy on Sun May 22 12:59:59 2022
    On Sun, 22 May 2022 12:14:54 +0100, Philip Herlihy wrote:

    In article <568c10e8-648d1ff0-17220c13.tiberius@james.kirk.invalid>, J???? ????
    wrote...
    [stuff with display:grid]

    That works! I have to say I have a real blind-spot for grid and flexbox. I get very little time these days to fool about with CSS, and it's often only when someone posts something interesting here that I get to think about it at all - while the skills I did have are atrophying all the time.

    I've looked at flexbox, but while it makes sense in the tutorials, it seems to
    me that you have to spend time working through examples really to get the hang
    of it, and time's short for me. Once I master flexbox (and I really must) I'll
    move on to grid. But it's clear that yours is the elegant and compelling solution to go for.

    I'm grateful to both of you for posting. But elegance is in the eye
    of the beholder. To me the p.letterdateline + * solution seems the
    more elegant, at least in my application. I concede that it may not
    be applicable in as many situations as J?'s.

    --
    Stan Brown, Tehachapi, California, USA
    https://BrownMath.com/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Siard@21:1/5 to Stan Brown on Wed Feb 5 12:57:44 2025
    I just discovered this newsgroup. I wonder whether anybody is still around. We'll see.
    The question below is almost three years old. Although a solution was
    found then, just out of interest I'd also like to mention a more modern solution.


    On Fri, 20 May 2022 -0700, Stan Brown wrote:
    Do I need a vacuous <div> to accomplish this, or is there something I
    can apply to the selector that actually contains text?

    I am formatting some letters. Each letter is headed by a dateline of
    two or three short lines, such as
    Villa Miranda
    Corfu
    Thursday

    I put this block against the right-hand margin, but have the lines
    within it aligned at the left. In other words, the last character of
    the longest line is against the right margin, and the first character
    of the shorter lines are left-aligned with the first character of the
    longest line. This all works fine, with this selector:

    p.letterdateline { float:right;
    margin-left:auto; margin-right:0;
    text-align:left; text-indent:0; }

    I want the first line of the letter ("Dear Smith:") to begin (at the
    left) on the next line after the last line of the class
    letterdateline heading. I know I can get that by inserting <div style="clear:both"></div> after the </p> of the letterdateline, but I
    hate using vacuous elements.
    [....]
    Is a vacuous <div> the only way to do what I want, or can I do
    something with the p.letterdateline selector?


    Float was invented to let text flow around images. Nowadays it is still
    useful for that purpose, but for all sorts of layout we now have flex
    and grid layout.
    This would be the code using flex:

    <div style="display:flex; justify-content:flex-end">
    <div style="flex:0 0 auto">
    Villa Miranda
    <br>Corfu
    <br>Thursday
    </div>
    </div>
    <p>(Rest of letter)</p>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Allodoxaphobia@21:1/5 to Siard on Fri Feb 7 13:30:54 2025
    On Wed, 5 Feb 2025 12:57:44 +0100, Siard wrote:

    I just discovered this newsgroup. I wonder whether anybody is still
    around. We'll see.

    Yep. The activity is light, and I mostly lurk.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Siard@21:1/5 to Allodoxaphobia on Tue Feb 11 13:44:44 2025
    On Fri, 7 Feb 2025 13:30:54 GMT, Allodoxaphobia wrote:
    On Wed, 5 Feb 2025 12:57:44 +0100, Siard wrote:

    I just discovered this newsgroup. I wonder whether anybody is still
    around. We'll see.

    Yep. The activity is light, and I mostly lurk.

    Webdesign is an interesting subject though, and I do not see any other
    usenet groups about this subject.

    I have some remarks concerning W3Schools. I always considered it to be
    very good, but recently I discovered MDN Web Docs, which appears to be
    more complete in some respects.

    https://developer.mozilla.org/en-US/docs/Learn_web_development

    So let me mention a few examples.

    1.
    W3S knows the 'clearfix hack', which is used to keep a floating image
    within its container.
    MDN knows a more modern way: it applies style="display:flow-root" to the container. It was specially invented for this purpose, so a hack is not
    needed any more. However, W3S does not know 'flow-root' yet.

    2.
    style="flex:" expects three values, e.g. style="flex: 2 1 50px".
    But in W3S's examples, there is also style="flex:1" or style="flex:50%".
    So how to interpret this? It can be found nowhere in W3S.
    MDN, on the other hand, explains clearly the meaning of one, two or three arguments.

    3.
    In grid layout, W3S mentions something like this in its examples: grid-template-columns: 1fr 1fr 1fr;
    But what is a 'fr'? W3S seems to have forgotten to mention this.
    MDN, on the other hand, explains clearly the purpose of the fr unit.

    4.
    MDN explains the differences between flex layout and grid layout, and in
    which cases it is needed, or at least better, to use either of them.
    These are very valuable insights, but they are lacking in W3S.

    Anyway, these are just a few points that I encountered, there are probably more. I think it is best to get your information from W3S as well as MDN.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)