Compare the effects of alternating colors with CSS and table code for each row

Source: Internet
Author: User
css| comparison

Use CSS to write the effects of alternate colors for each row of tables

about using CSS definitions to show different colors for each row of the table to differentiate each row of data for easy reading. Some of the use of IE bugs, in the CSS to add dynamic content, IE will parse it, this is not to talk about, because and the subject does not matter.

Also see a few very simple methods, the use of different labels different background color to achieve results, first look at this method of CSS

th {font-weight:normal; Text-align:left background: #CCCCCC}
TD {background: #FAFAFA}

Page code

<table>
<tr>
<th> First Color </th>
</tr>
<tr>
<td> Second Color </td>
</tr>
<tr>
<th> First Color </th>
</tr>
<tr>
<td> Second Color </td>
</tr>
<tr>
<th> First Color </th>
</tr>
<tr>
<td> Second Color </td>
</tr>
</table>

Use TD and TH, respectively give different background color, to achieve the effect. However, each label has its own special meaning, if this method is to split the data, easy to view, then the th loses its original meaning, th it represents a column of topics, and here it is only to give the table each row different background color.

Web standardization, a very important point is the semantics of the label, here just want to say that this method is really clever, it is simple to use, but contrary to the basic things of standardization, if you do not care, you can use it, even through verification.

There's a lot to be said about semantic content, and it's just a chance to see it and then start.

Change background color or picture when mouse passes

can be used for table TD, but also can be used on Div, similar to IBM's effect

Change background color when mouse passes

<TABLE><TR><TD width= "height=" bgcolor= "#DDC676" >ihandu</td></tr></ Table>

Change background picture when mouse passes

<TABLE><TR><TD width= "height=" background= "/images/2.gif" >ihandu</td></tr> </table>



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.