Text background colour

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • KiwiBrian

    Text background colour

    Using a div and css how do I have a text background colour that
    automatically adjusts to the size and amount of the text string?

    TIA
    Brian Tozer


  • Bart

    #2
    Re: Text background colour

    Op Sun, 6 Mar 2005 05:12:13 +1300 schreef "KiwiBrian"
    <briantoz@ihug. co.nz>:
    [color=blue]
    >Using a div and css how do I have a text background colour that
    >automaticall y adjusts to the size and amount of the text string?
    >
    >TIA
    >Brian Tozer
    >[/color]

    You mean the bacground only applies to the text, not to the entire
    div?
    In that case:

    in your HTML

    <div>
    This text does not have background color yellow.
    <span class="test">So me text with background color yellow.</span>
    This text does not have background color yellow either.
    </div>


    In your CSS

    span.test{
    /* pick any color you like */
    color: black;
    background-color: yellow;
    }

    (not tested, just on the top of my head [if that's correct English])

    Bart

    --
    Bart Broersma
    broersma.juda_A NTISPAM_@tiscal i.nl
    (ff _ANTISPAM_ wegpoetsen uit dit adres natuurlijk)

    Comment

    • phil_gg04@treefic.com

      #3
      Re: Text background colour

      > Using a div and css how do I have a text background colour that[color=blue]
      > automatically adjusts to the size and amount of the text string?[/color]

      You can't; you need a SPAN inside the DIV.

      --Phil.

      Comment

      • KiwiBrian

        #4
        Re: Text background colour


        "KiwiBrian" <briantoz@ihug. co.nz> wrote in message
        news:d0clot$pgk $1@lust.ihug.co .nz...[color=blue]
        > Using a div and css how do I have a text background colour that
        > automatically adjusts to the size and amount of the text string?[/color]

        Thanks Bart and Phil.
        Really appreciate it.
        Brian.


        Comment

        • Evertjan.

          #5
          Re: Text background colour

          wrote on 05 mrt 2005 in comp.infosystem s.www.authoring.stylesheets:
          [color=blue][color=green]
          >> Using a div and css how do I have a text background colour that
          >> automatically adjusts to the size and amount of the text string?[/color]
          >
          > You can't; you need a SPAN inside the DIV.
          >[/color]

          I think you can.

          <div style='display: inline;backgrou nd-color:red;'>abc xyz</div>

          --
          Evertjan.
          The Netherlands.
          (Replace all crosses with dots in my emailaddress)

          Comment

          • phil_gg04@treefic.com

            #6
            Re: Text background colour

            >>> Using a div and css how do I have a text background colour that[color=blue][color=green][color=darkred]
            >>> automatically adjusts to the size and amount of the text string?[/color]
            >> You can't; you need a SPAN inside the DIV.[/color]
            > I think you can.
            > <div style='display: inline;backgrou nd-color:red;'>abc xyz</div>[/color]

            OK, you can. But then it doesn't look like a DIV any more. You can
            also do it by floating it, for example. But I suspect that Brian wants
            to have a background color while keeping the normal DIV behaviour.

            --Phil.

            Comment

            • Evertjan.

              #7
              Re: Text background colour

              wrote on 06 mrt 2005 in comp.infosystem s.www.authoring.stylesheets:
              [color=blue][color=green][color=darkred]
              >>>> Using a div and css how do I have a text background colour that
              >>>> automatically adjusts to the size and amount of the text string?
              >>> You can't; you need a SPAN inside the DIV.[/color]
              >> I think you can.
              >> <div style='display: inline;backgrou nd-color:red;'>abc xyz</div>[/color]
              >
              > OK, you can. But then it doesn't look like a DIV any more. You can
              > also do it by floating it, for example. But I suspect that Brian wants
              > to have a background color while keeping the normal DIV behaviour.[/color]

              Sure Phil,

              I agree with your suspicion,
              but answering on what you believe the OP is asking
              only makes things worse.

              --
              Evertjan.
              The Netherlands.
              (Replace all crosses with dots in my emailaddress)

              Comment

              • Lauri Raittila

                #8
                Re: Text background colour

                in comp.infosystem s.www.authoring.stylesheets, KiwiBrian wrote:[color=blue]
                > Using a div and css how do I have a text background colour that
                > automatically adjusts to the size and amount of the text string?[/color]

                Your question is quite unclear, but you can use:
                display:table;

                float:left;

                display: inline;display: inline-table;display:i nline-block;

                or

                display:inline

                Each has issues. To know what is suitable for your case, context would be
                needed.




                --
                Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
                Utrecht, NL.

                Comment

                Working...