Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Styling the width on non-breaking space

  • This topic is empty.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #202397
    inktrap
    Participant

    I’d like to make my non-breaking spaces have a certain width (French punctuation), without resorting to font-size. Here’s what I tried:

    span.sp-thin-fr {
        display: inline-block;
        width:   0.125em;  /* 1/8 em */
        }
    

    …but display: inline-block; overrides the non-breaking property.

    Any ideas?

    #202399
    Senff
    Participant

    Not sure why it’s not working for you (or maybe I misunderstand). I do see some space between the last word and the period:

    http://codepen.io/senff/pen/aOZzay

    #202401
    inktrap
    Participant

    It’s working, but the space is treated as regular instead of non-breaking, so punctuation breaks of at the end of line.

    #202430
    inktrap
    Participant

    That’s right, it’s as if there’s a normal space in html.

    #202443
    Paulie_D
    Member

    As I understand it. French punctuation is preceded by a space.

    In this case a non-breaking space is required as there will be occasions when the very last item on the end would be the punctuation.

    …and this would break.

    http://codepen.io/Paulie-D/pen/xGORLa

    #202444
    Senff
    Participant

    Duh. I should’ve seen that.

    Instead of giving it a width and display:inline-block; just give it some horizontal padding.

    http://codepen.io/senff/pen/EjyNop

    #202713
    inktrap
    Participant

    The problem is it has to be narrower than a regular space, usually 1/8 of an em.

    I could give it a negative margin, but there’s no way to calculate how much to get the exact width, since every font has a slightly different space.

    The only option I see is to use the code from my original post and wrap everything in nowrap span, but that overloads the content with way too much markup.

    #202716
    Paulie_D
    Member
    #252395
    apadeloup
    Participant

    It’s late to answer but the post is in good place in Google :
      does a better job than   as it is narrower no-break space.

Viewing 9 posts - 1 through 9 (of 9 total)
  • The forum ‘CSS’ is closed to new topics and replies.