Jump to content

[SOLVED] How do i stop my Style.CSS From taking Priority


Monk3h

Recommended Posts

How do i stop my Style.CSS From taking Priority over other coulour changes in Scripts?

 

For example, i want all Admins in Chat to have there name in red.. Only Problem is the CSS takes over and keeps all the colours the same.

 

 

How do i change it so Colour changes ion my Scripts take Priority over CSS?

Link to comment
Share on other sites

CSS precedence rules. Part of the overall rules known as Cascade (you'd think the acronym had no meaning?)

 

And they are as follows: (simplified, top has least priority):

 

External stylesheet (css file loaded from <link rel="stylesheet" ...>)
Internal stylesheet definitions (set by <style type="text/css"></style>)
Inline styles (set in (x)html tags through the style attribute)

 

There's another element that, while not relating to these simple precedence rules, may affect your perception of them; It's the Inheritance rules, that basically specify that some (read "many of the") css elements will inherit their rules from their parents. Details are available everywhere on the web.

 

Regardless, for your specific problem you want to go down in the list with your script and apply your php enforced rules to the lowest items, depending on what you have. Don't forget however that your php can also edit any in-place css file... or change the linked css file of an html document.

 

All in all what you need is a good understanding of how CSS works in terms of precedence (inheritance and  cascading). And what we need is a clear, concise (barebones please) snippet of your code and an explanation of what you want to do.

 

Link to comment
Share on other sites

This is my Style Sheet:

 

* {
color: black;
font-family: verdana;
font-size: 12px;
}
.td {
border-top: solid #575757 1px;
border-bottom: solid #575757 1px;
border-left: solid #575757 1px;
border-right: solid #575757 1px;
}
input, textarea, select {
color: black;
background: #B1B165;
border: solid #747d58 1px;
}
a {
text-decoration: none;
text-transform: none;
color: black;
}
a:hover {
text-decoration: none;
text-transform: none;
color: 0066cc;
}
body {
background: #FEE5AC;
}
body, iframe, select, textarea {
scrollbar-face-color: white;
scrollbar-highlight-color: black; 
scrollbar-shadow-color: black; 
scrollbar-3dlight-color: white; 
scrollbar-arrow-color: black;
scrollbar-track-color: white; 
scrollbar-darkshadow-color: white; 
scrollbar-base-color: white;
}

 

 

 

And this is my Chat Script:

 

<?php 
$title = "Chat"; include("header.php"); mysql_query("update players set page='Chat' where id=$stat[id]");
?>

<table width=100%>
<form method=post action=chat.php?action=chat>
<tr><td colspan=2 align=center>
[<a href=chat.php>refresh</a>] <input type=text name=msg size=55> <input type=submit value=Chat>
</form>

<?php
if ($action == chat) {
if ($msg) {
	if ($stat[rank] == Admin) {
		$starter = "<font color=0066cc>$stat[user]</font>";
	} else {
		$starter = "$stat[user]";
	}
	mysql_query("insert into chat (user, chat) values('$starter', '$msg')");
}
}
?>

</td></tr>
<tr><td width=400 valign=top>
<u><b>Chat</u></b><br><br>

<iframe src=chatmsgs.php width="113%" height=306 id=ifr name=ifr frameborder=0></iframe>

</td><td width=100 valign=top>
 </td></tr>
<tr><td colspan=2 align=center>

<?php
$numchat = mysql_num_rows(mysql_query("select * from chat"));
print "There are <b>$numchat</b> chat lines.";
?>

</td></tr>
</table>

<?php include("footer.php"); ?>

 

 

 

The CSS is Included in the Header and the header is Included in every File.

 

This is the Precise part of the code im having trouble with:

 

if ($stat[rank] == Admin) {
		$starter = "<font color=0066cc>$stat[user]</font>";
	}

 

 

That Wont Apear in a diferent colour..

Link to comment
Share on other sites

Because color is an HTML attribute that gets overridden by any css - anywhere - that happens to alter that element color. And if that is not enough, the color html attribute is also deprecated in favor of exactly css.

 

What you want is:

 

$starter = "<span style='color:#0066cc'>$stat[user]</span>";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.