WordPress blogging: Adding a style sheet to WordPress
The tutor shows a way to add a style sheet to a WordPress site.
There are several ways to add a style sheet to WordPress. Herein, I’ll show how I’ve done so.
Let’s imagine the div below is meant to be styled from an external style sheet:


Assuming the div above is class=”hair”, the following style sheet could be added as /blog/styles/hairstyle.css
.hair{
display:block;
margin:auto;
font-size:200%;
color:white;
background-color:pink;
text-align:center;
width:50%;
}
Next, the following code, added inside the WordPress Theme Functions file, includes the style sheet as the page is rendered:
function hairstyle(){
wp_register_style(‘hairstyle’,’/styles/hairstyle.css’);
wp_enqueue_style(‘hairstyle’);
}
add_action(‘wp_enqueue_scripts’,’hairstyle’);
This method takes concentration to apply. I normally use inline styles, but sometimes an external style sheet makes more sense.
I’ll be talking more about WordPress in future posts:)
Source:
Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.
Leave a Reply
You must be logged in to post a comment.