Jump to content
Larry Ullman's Book Forums

I can't apply css rules to a tag in a php page

Recommended Posts

I was trying to solve the second exercise (Pursue) of the third chapter, namely to add  a textarea and a checkbox. I haven't created a new form, I have reused your form, I have simply added the textarea and made it a sticky form again (My textarea is deliberately optional).

But I encountered a problem that was a very "pain in the ass" (I'm not a native english, it is a dirty word? sorry if is this the case 😇).

I tried to style my textarea, with a background-color:red and a resize:vertical properties in css/sticky-footer-navbar.css but they don't work. If I give them as inline style instead they work.

I'm not able to figure out what is the problem, may be I'm missing something.

There is the attached code, it's very very similar to your code. Little change described above.

Please, can you help me to understand where I'm wrong? 

Thanks in advance



Edited by NickReferee
Link to comment
Share on other sites

Hi Larry,

I have resolved on my own (really with the aid of stackoverflow).

It's a cache problem.

I have substituted my css link tag with him:

<link href="css/sticky-footer-navbar.css?v=<?php echo time(); ?>" rel="stylesheet">

to force to use the fresh version (surely I could to empty the cache too).

Or I could include the css like that:

  <?php include "css/sticky-footer-navbar.css" ?>

However those above are not the best solutions because force ever the browser to make an http request to download the css file (thus the user will never use the cache copy though if my css has not been changed). The best way is to use:

<link href="css/sticky-footer-navbar.css?v=1" rel="stylesheet">

And when I change the css file I have to remember to do:

<link href="css/sticky-footer-navbar.css?v=2>" rel="stylesheet">

to force the download instead of the cache version.

I haven't closed the post because could be useful to someone else.

This link https://stackoverflow.com/questions/50662906/my-css-file-not-working-in-my-php-file helped me



Link to comment
Share on other sites


  • Create New...