0

I have recently updated a CSS file onto the web with a slight change in, to make a certain text blue instead of red:

p.melding{
    font-weight: bold;
    color: blue; /*red earlier*/
}

The file has been updated online, but the change is not displaying online (nor any other changes I have made to the CSS script). When I look in the style editor in the web developer tool in Firefox, it says red. (When I change it in that editor it changes to blue.)

The style sheet seems to work in general, so shouldn't be an issue with the code there. Below are the relevant parts of my html/php file. Although this has been written by someone else (professional) and there has not been a problem with it earlier, so I think the problem lies somewhere else.

The link to the stylesheet:

  <head>
    <title>...</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link rel="stylesheet" href="stil.css" type="text/css" media="screen" />
  </head>

and the php code concerning the class in question:

<?php
  if (isset($melding)) {
    echo "            <p class=\"melding\">$melding</p>\n";
  }
?>

Any ideas why the changes to my CSS file are not showing online?

Ingrid
  • 516
  • 6
  • 18

3 Answers3

0

Try this, I hope that it works for you:

p.melding{
   font-weight: bold !important;
   color: blue !important; 
}

It usually happens, if your CSS is getting overridden again, maybe by some other file.

A couple notes about using !important.

Hope it helps you out!!

hungerstar
  • 21,206
  • 6
  • 50
  • 59
Amit Horakeri
  • 747
  • 5
  • 18
  • He has said it shows as red when he inspects the element. – rybo111 Sep 14 '15 at 13:29
  • Thats rite, but it also happens, if the css is getting overridden in someother file. As CSS follows a top-down approach. The later css is the one that is captured and applied. – Amit Horakeri Sep 14 '15 at 13:30
  • You can read more about the !important here. http://www.impressivewebs.com/everything-you-need-to-know-about-the-important-css-declaration/ – Amit Horakeri Sep 14 '15 at 13:33
  • Yes, CSS can be overridden. But in this case if you inspect the element (at least in Chrome), the prioritised rule is what's shown first - therefore adding `!important` won't do anything. His changes are not being shown. It's more likely to be a cached CSS issue. – rybo111 Sep 14 '15 at 13:38
0

The problem was that the page had not been cached. Doing Ctrl+F5 (in the web browser) solved it.

The caching depends on the browser and the server, so it varies if this is an issue or not when updating CSS files.

Ingrid
  • 516
  • 6
  • 18
0

Try using the following

<?php
  if (isset($melding)) {
  echo "            <p class='melding'>$melding</p>\n";
  }
?>

If that does not work clear the browser cache and restart the browser.

Ronald P Mathews
  • 2,178
  • 1
  • 22
  • 26