0

I've got a html page with styling in the <style></style> tags in the header and a php block with some includes in the body.

At the very top i've got this:

a:link {color: inherit;}      /* unvisited link */
a:visited {color: inherit;}  /* visited link */
a:hover {color: inherit;}  /* mouse over link */
a:active {color: inherit;}  /* selected link */

In the navigation bar (one of the php includes) i've got this:

a:link {color:white; text-decoration:none;}      /* unvisited link */
a:visited {}  /* visited link */
a:hover {text-decoration:underline;}  /* mouse over link */
a:active {}  /* selected link */

And the problem is i've got some <a href> email links on the same page under the php includes which are turning white, on a white background. How can I override the included php file so my email links can be black while keeping the white navigation bar links?

Loading Sequence:

  1. Inline style
  2. Body
  3. php includes
  4. The <a href> emails links which are turning white

3 Answers 3

2

When you do an PHP include, it is basically just dumping that HTML into the document. So you need to either make the link a class like the individual above me stated (and add that class into your CSS document) or you need to use some inline CSS to overwrite the general rule set in your CSS document. This inline CSS would need to be in that PHP file itself that you are including.

Sign up to request clarification or add additional context in comments.

Comments

0

Give the email links a class

html

 <a href="" class="email_link"></a>

css

.email_link{
  color: #000!important;
 }

3 Comments

I thought !important was 'bad', i'm not entirely sure what it does (it has fixed the problem) but why is it bad?
@Crizly It's a bad practice: stackoverflow.com/questions/3706819/…
There is no need for !important here.
0

sometimes if you lost in seeking the right place to change the css, change it inline. using:

<a href="#" style="color:blue"> link </a>

2 Comments

In the team I lead I disallow use of inline styles. They are a maintenance nightmare. Prefer (first choice) a separate .css file or (second choice) a <style></style> block in the head of the page.
I totally agree with you :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.