skip to Main Content

this is the result i want
this is the result i am getting(ignore the image)

This is my code

<html>
    <head>
        <title> Practical 4 </title>
        <meta  charset ="UTf-8">
    </head>
    <body bgcolor ="lightblue">
        <table border="1" bordercolor="black"  cellspacing="1" align ="center">
        <tr>
        <td bordercolor ="red"> ** </td>
        <td bordercolor ="blue"> আমার </td>
        <td bordercolor ="green">দেশের </td>
        <td bordercolor = "red" >**</td>
        </tr>
        <tr>
        <td bordercolor ="red">**</td>
        <td bordercolor ="darkblue" colspan="2" rowspan="2"> <img src="image_to_use.jpg"></td>
        <td bordercolor ="red"> ** </td>
        </tr>
        <tr>
        <td bordercolor ="red" >**</td>
        <td bordercolor ="red" >**</td>
        </tr>
        <tr>
         <td bordercolor ="red"> ** </td> 
         <td bordercolor ="blue">নাম</td>
         <td bordercolor ="green">বাংলাদেশ </td> 
         <td bordercolor ="red">**</td>
         </tr>
        </table>
    </body>
</html> 
    
    
        

it would be very helpful if i could know how to color particular table cells

2

Answers


  1. Instead of HTML attributes, you should use CSS.
    You can color your cells with for loop in JS.

    Login or Signup to reply.
  2. You can color your table cells with access specifier. If you want to apply the same color to multiple cells use ‘class’.

    **

    if you want to apply different color to each cell use ‘id’;

    **

    In CSS:

    Style based on class

    .classname{
        background-color: red;
    }
    

    Style based on id

    .idname{
        background-color: red;
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search