how to specify background text rectangle color in CSS


Tags: html,css

Problem :

I want to specify background color for HTML using CSS. If my foobar.css file is

back {
  background-color: #808080;
}

and my index.html is

<link href="foobar.css">

<p><back>foo</back></p>
<p><back>foobar</back></p>

then this does not work perfectly: yes the lines have background, but the background only covers the line length, so it is jagged on the right side, and the background does not cover the space between the lines.

How to do it so that the background covers the whole rectangle around the paragraphs?

I tried foobar.css like

table {
  background-color: #808080;
}

and then reference that in index.html like

<table>
<p>foo</p>
<p>foobar</p>
</table>

but this is completely ignored.



Solution :

Hope this solves your isuue

    <table>
        <tr>
            <td>
               <p>foo</p>
               <p>foobar</p>
            </td>
       </tr>
    </table>
  <style>
      table{background-color:red;}
  </style>

    CSS Howto..

    How to make div blocks not floating using CSS?

    How to show middle of image in div using css?

    how to trace this computed CSS value in firefox inspector?

    How to local storage expand/collapse CSS settings

    How to use box shadow in css?

    How to move the jQueryUI close button on the dialog over the top of top right corner?

    How can I make this container and table responsive for mobile and ipad size?

    css how to make H2 tag look same as H3 tag (turned out hard!)

    how to position icon just after h2 tag using :after pseudo even though 100% width

    How to hide child element entirely if it is cut off by it's parent's overflow:hidden property?

    How to Add Class to Bootstrap Thumbnails on Slider Change

    How to get my “Register Now!” Link's to line up at the bottom using CSS

    How to get MetroUI CSS Datepicker value with javascript

    How to have an image zoom in and out automatically in the background

    How to fix redefinition warnings from CSS Validator?

    How to make a very simple coloured 1-line text area?

    how to reference background image urls in css through config entrys

    How to style