FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

css

 


sunpascal
is there a way to apply certain settings to elements within another element?
ok... example

Code:


<style>
.someclass{font-weight:bold;}
</style>

<div class="someclass">

test

<table border="1">
<tr>
<td>some text</td>
<td>some text</td>
</tr>
<tr>
<td>some text</td>
<td>some text</td>
</tr>
</table>

</div>


say i want to apply the same settings to all the text in the <div> section including my table.
so not just the word "test" but also "some text" etc should be bold.

of course i could add class=" .... to all the <td> tags but it there a nicer way?
sonam
Code:
<style type="text/css">
<!--
*{font-weight: bold}
-->
</style>


will bold all text in your html and you don't need to write class in tags.

Code:
<style type="text/css">
<!--
p,td,div{font-weight: bold}
-->
</style>


will bold all text in chosen tags (p, td, div) and you don't need to write class in this tags.

Sonam
sunpascal
ok... i am a bit confused here:

won't this also affect p, td, and div elements outside the <div> section?
sonam
OK,
then you have two different choise. If you want p, TD (etc.) bolded in all divs then use:

Code:
<style type="text/css">
<!--
div TD, div p {
font-weight: bold
}
-->
</style>


If you want bold only in chosen divs then you can use:
Code:
<style type="text/css">
<!--
div.bold TD, div.bold p {
font-weight: bold
}
-->
</style>


In that case your div must have class definition for chosen div (class="bold" - in my example)

Sonam
sunpascal
thanks - I had been looking for that!
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.