Title: CSS : External Stylesheet
Last modified: July 10, 2024

---

# CSS : External Stylesheet

 *  Resolved [corrinarusso](https://wordpress.org/support/users/corrinarusso/)
 * (@corrinarusso)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/css-external-stylesheet-2/)
 * Hi all! Can someone please show me how to load my CSS file from my php template?
 * My template has over 600 lines of CSS, so I’m just trying to clean it up a bit.
 * I have already tried this:
 * [https://docs.gravitypdf.com/v6/developers/filters/gfpdf_include_list_styles](https://docs.gravitypdf.com/v6/developers/filters/gfpdf_include_list_styles)
 * and this:
 * $stylesheet = file_get_contents(‘assets/mpdfstylePaged.css’);
   $mpdf->WriteHTML(
   $stylesheet,1); // The parameter 1 tells that this is css/style only and no body/
   html/text
 * without success.
 * Thanks! Corrie

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [corrinarusso](https://wordpress.org/support/users/corrinarusso/)
 * (@corrinarusso)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/css-external-stylesheet-2/#post-17880788)
 * Of course, as soon as I posted here I implemented the soltion.
 * 🙂
 * I’ll leave this here if anyone else was looking for the solution, just add the
   usual link rel in your php template file, and include the full path to the file,
   i.e.:
 * <link rel=”stylesheet” href=”/wp-content/uploads/PDF_TEMPLATE/file_name_template.
   php” />
 *  Plugin Author [Jake Jackson](https://wordpress.org/support/users/blue-liquid-designs/)
 * (@blue-liquid-designs)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/css-external-stylesheet-2/#post-17882096)
 * Glad you were able to find a solution [@corrinarusso](https://wordpress.org/support/users/corrinarusso/).
 * The PDF engine Gravity PDF uses supports the loading of stylesheets over HTTP(
   S) or loading directly form the file system. The latter option is faster, as 
   it’s one less network request to make:
 *     ```wp-block-code
       <!-- Load stylesheet over the internet (slower) --><link rel="stylesheet" href="https://test.com/wp-content/uploads/PDF_EXTENDED_TEMPLATES/my-stylesheet.css" /><!-- Use a relative path loads the stylesheet over the internet (slower) --><link rel="stylesheet" href="/wp-content/uploads/PDF_EXTENDED_TEMPLATES/my-stylesheet.css" /><!-- Load stylesheet directly from the server (faster) --><link rel="stylesheet" href="<?php echo esc_attr( __DIR__ . '/my-stylesheet.css' )" />
       ```
   
 * If you still need PHP in the stylesheet file so you can conditionally apply CSS
   based on form data, you can always `include` the PHP file:
 *     ```wp-block-code
       <style><?php include __DIR__ . '/my-stylesheet.php'; ?></style>
       ```
   
 * For anyone else interested in this topic, [this code goes in your custom PDF template](https://docs.gravitypdf.com/v6/developers/first-custom-pdf).
    -  This reply was modified 1 year, 9 months ago by [Jake Jackson](https://wordpress.org/support/users/blue-liquid-designs/).
      Reason: Include example of loading the stylesheet with a relative path, which
      still uses a network request

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘CSS : External Stylesheet’ is closed to new replies.

 * ![](https://ps.w.org/gravity-forms-pdf-extended/assets/icon-256x256.png?rev=3168987)
 * [Gravity PDF](https://wordpress.org/plugins/gravity-forms-pdf-extended/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/gravity-forms-pdf-extended/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/gravity-forms-pdf-extended/)
 * [Active Topics](https://wordpress.org/support/plugin/gravity-forms-pdf-extended/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/gravity-forms-pdf-extended/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/gravity-forms-pdf-extended/reviews/)

## Tags

 * [css](https://wordpress.org/support/topic-tag/css/)
 * [Stylesheet](https://wordpress.org/support/topic-tag/stylesheet/)

 * 2 replies
 * 2 participants
 * Last reply from: [Jake Jackson](https://wordpress.org/support/users/blue-liquid-designs/)
 * Last activity: [1 year, 9 months ago](https://wordpress.org/support/topic/css-external-stylesheet-2/#post-17882096)
 * Status: resolved