开发者

css for all tags of a class [closed]

开发者 https://www.devze.com 2023-03-25 22:29 出处:网络
开发者_如何学Go It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form
开发者_如何学Go It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

How can I specify css for all td tags of a table of a certain class? I tried this:

.myclass td {padding: 1px;}

But it doesn't work. The html is:

<table class="myclass"><tr><td>foo


Your example should work. Double check:

  • Case (ie: .myclass is not the same as .myClass)
  • That the styling is valid for a Table Cell

Here's a working example: http://pastehtml.com/view/b2oxzzdp4.html


Try this

.myclass tr td {padding: 1px;}

Although it should work the same.

You may need to add more than 1px of padding to see a difference. Perhaps it is working and you cannot see the change.


table.myclass td 
{
padding: 1px;
}


Strange, I believe it should work. Check browser console for any errors.
And you can use for table cell padding table attribute cellpadding

<table cellpadding="1">
</table>


You aren't closing your tags. Other than that, it works.


To answer your actual question, you specify CSS for a <td> tag of a table of a certain class just like you did it in your question:

.myclass td { /* whatever */ }

Whether that CSS is what you want is another story.

If you have other items that share that class, and you want to make sure it's a table specifically, you can do this:

table.myclass td { /* whatever */ }
0

精彩评论

暂无评论...
验证码 换一张
取 消