Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Override external style sheet

Status
Not open for further replies.

bluedollar

Programmer
Jul 24, 2003
174
GB
I have an external style sheet that provides default values for all my formatting in my web site.

However I would like to override certain default values, on perticular sections on particular pages.

For example:

echo'<table border="0" cellspacing="0"><tr><th align="left" class="3">Description</th><th align="left" class="3">Num Of Places</th><th align="left" class="3">Price </th></tr>';

On the above line I want to keep the colour/size/font settings in the external style sheet, but I want to align the text left (default is set to right).

Is there a way that I can easily change the formatting for this one line, not the whole page.

Sorry about the simplistic nature of the question, but I am new to CSS.

Any help would be greatly appreciated.

Thanks

Dan
 
Use inline CSS (e.g. style="text-align: right;") - it will override external rules.
 
That'll work but if you have more than one place where to change things then it gets old pretty fast. Specially if you want to add/change another attribute.
Try this little trick

Code:
<html>
<body> 
<style>
.boxright{
background-color:#0000CC;
color:#FFFFFF;
font-weight:bolder;
border:thin solid black;
text-align:right;
width:200px;
}
.boxleft{
text-align:left;
}
</style> 
<table border="0" cellspacing="0"> 
<tr> 
  <th class="boxright" >Description</th> 
  <th class="boxleft">Num Of Places</th> 
  <th [b]class="boxright boxleft"[/b]>Price </th> 
</tr> 
</table>
</body>
</html>

declaring things like this will override your common attributes but keep the ones from boxrigth.
The goood thing about it is you only need to cahnge attribute once at the boxleft level and all your elements will change accordingly even if you have 500 of them.


Good luck.

grtfercho çB^]\..
"Imagination is more important than Knowledge" A. Einstein
-----------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top