Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have several ways to do this.</p> <p>You may specify CSS properties directly in the <code>style</code> attribute of HTML tags, but that can quickly become tedious as you might have to insert code in scattered areas in the middle of your content, making maintenance harder.</p> <p>You can also put all style definitions between <code>&lt;style&gt;&lt;/style&gt;</code> tags inside the <code>&lt;head&gt;</code> section, which partly eliminates the disadvantage of mixing content with presentation.</p> <p>Finally, it is also possible to produce CSS files with PHP using database informations. Rename your stylesheet <strong><i>something</i>.php</strong>, then put this at the top of the file :</p> <pre><code>&lt;?php header('content-type: text/css'); ?&gt; </code></pre> <p>This tells PHP that the content it will generate needs to be sent as a CSS file, so that the user's browser knows that it's a stylesheet. All that's left to do is to correctly reference your "mutable" stylesheet in the PHP script that holds your HTML content :</p> <pre><code>&lt;link href="../layout/css/something.php" rel="stylesheet" type="text/css" media="all" /&gt; </code></pre> <p>This will allow you to use this kind of things in your "CSS" file :</p> <pre><code>body { background-color: &lt;?php echo $userstyle['color']; // Retrieved from database somewhere above ?&gt;; } </code></pre> <p>However, if you care about performance, the latter solution may need some improvement using the <em>Cache-control</em> header, to avoid reloading the CSS file whenever the user follows a link in your website.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload