Reply 356458 to: External Stylesheet not working as expected

Avatar: Tony Rodriguez
Tony Rodriguez
Support staff
May 12, 2023 at 09:28

Hello, @invis,

To use an external style sheet on a particular page, you can add the link to the external stylesheet in the <head> section of your HTML code, within the <head> tags.

Here’s an example of how to add a link to an external stylesheet in HTML:

<!DOCTYPE html>
<html>
  <head>
    <title>My Web Page</title>
    <link rel="stylesheet" type="text/css" href="mystyle.css">
  </head>
  <body>
    <!-- Your HTML content here -->
  </body>
</html>

Make sure that the href attribute in the link tag is pointing to the correct path of your external stylesheet.

If the above method is not working for you, you can try using wp_enqueue_style() function in your theme’s functions.php file.

Here’s an example of how to enqueue a stylesheet in WordPress using wp_enqueue_style():

function my_styles() {
  if (is_page('your-page-slug')) { // replace with your page's slug
    wp_enqueue_style('my-style', get_template_directory_uri() . '/mystyle.css');
  }
}
add_action('wp_enqueue_scripts', 'my_styles');

In the above example, the is_page() function

Best Regards,
8Theme’s Team

Go To The Whole Conversation In Topic
We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.