How to Add CSS Code Snippets with WPCode
Content
Adding custom CSS is a common task for WordPress site owners looking to tweak their site's appearance. If you're using the WPCode plugin to manage your code snippets, you might have noticed there isn't a dedicated "CSS" code type in the dropdown menu. This can lead to confusion when a snippet containing pure CSS doesn't work as expected.
This guide explains the correct way to add CSS using WPCode's existing options.
Why Your CSS Snippet Might Not Work
When you add a CSS rule like .textmarkergelb { background-color:yellow; } directly into a WPCode snippet using the "Universal" code type, it is treated as plain text. Browsers cannot interpret plain text as a styling rule, so the styles are not applied to your site.
For CSS to work, it must be wrapped in HTML <style> tags so the browser recognizes it as a style sheet.
The Solution: Use the HTML Code Type
To successfully add CSS with WPCode, follow these steps:
- In your WPCode snippet, set the Code Type to "HTML".
- Wrap your CSS code within standard HTML
<style>tags within the code editor.
Example:<style>
.textmarkergelb {
background-color: yellow;
}
</style> - Choose an appropriate Insertion Location. For site-wide CSS, "Site Wide Header" is a common and effective choice, as it loads the styles early in the
<head>section. - Save and activate your snippet.
This method instructs the browser to correctly interpret the code inside the tags as CSS, allowing your styles to be applied.
Community Feedback and Future Improvements
This workaround is well-established among WPCode users. Based on community feedback in the support forums, many users have requested that the WPCode team add a dedicated "CSS" code type that automatically adds the necessary <style> tags for convenience. While this is not a current feature, it has been noted as a popular suggestion for future development.
For now, using the HTML code type is the confirmed and reliable method for adding CSS to your site with the WPCode plugin.
Related Support Threads Support
-
Can I include a perl script?https://wordpress.org/support/topic/can-i-include-a-perl-script/
-
how to set the screen options to show more snippets on each page?https://wordpress.org/support/topic/how-to-set-the-screen-options-to-show-more-snippets-on-each-page/
-
Where to find more useful snippets ?https://wordpress.org/support/topic/where-to-find-more-useful-snippets/
-
How to Create Description for RSS Feedhttps://wordpress.org/support/topic/how-to-create-description-for-rss-feed/
-
[Feature ?] error supporthttps://wordpress.org/support/topic/feature-error-support/
-
Add CSS to admin sectionhttps://wordpress.org/support/topic/add-css-to-admin-section/
-
Add CSS snippet – where?https://wordpress.org/support/topic/add-css-snippet-where/
-
Shortcode Naminghttps://wordpress.org/support/topic/shortcode-naming/
-
Can’t add JSON snippethttps://wordpress.org/support/topic/cant-add-json-snippet/
-
Does creating more snippet will making more lines and slow down my website?https://wordpress.org/support/topic/does-creating-more-snippet-will-making-more-lines-and-slow-down-my-website/
-
Why isn’t there a searchhttps://wordpress.org/support/topic/why-isnt-there-a-search/
-
Option to Find and List more Snippetshttps://wordpress.org/support/topic/option-to-find-and-list-more-snippets/
-
feature request: add short code to the main pagehttps://wordpress.org/support/topic/feature-request-add-short-code-to-the-main-page/
-
Sidebar label name changehttps://wordpress.org/support/topic/sidebar-label-name-change/
-
incomplete library snippet: Add an Edit Post Link to Archiveshttps://wordpress.org/support/topic/incomplete-library-snippet-add-an-edit-post-link-to-archives/
-
Any plans to add sync?https://wordpress.org/support/topic/any-plans-to-add-sync/
-
Easily create custom shortcodehttps://wordpress.org/support/topic/easily-create-custom-shortcode/
-
add css codehttps://wordpress.org/support/topic/add-css-code/
-
Insert snippets globally across entire multi-site networkhttps://wordpress.org/support/topic/insert-snippets-globally-across-entire-multi-site-network/
-
Migrate Snippets from one website to anotherhttps://wordpress.org/support/topic/migrate-snippets-from-one-website-to-another/
-
how to choose snippet to show in mobile, desktop or tablet?https://wordpress.org/support/topic/how-to-choose-snippet-to-show-in-mobile-desktop-or-tablet/
-
Enable Gutenberg blockshttps://wordpress.org/support/topic/enable-gutenberg-blocks/
-
Please add Global Code support for Multisitehttps://wordpress.org/support/topic/please-add-global-code-support-for-multisite/
-
Can We Run Code Snippets On Specific Pages?https://wordpress.org/support/topic/can-we-run-code-snippets-on-specific-pages/
-
download codes/Export snippetshttps://wordpress.org/support/topic/download-codes-export-snippets/
-
Can I add my own Code Snippet?https://wordpress.org/support/topic/can-i-add-my-own-code-snippet/
-
How do i add a Php snippet?https://wordpress.org/support/topic/how-do-i-add-a-php-snippet/
-
Sort by “Name”https://wordpress.org/support/topic/sort-by-name-6/
-
Please add $library_url filterhttps://wordpress.org/support/topic/please-add-library_url-filter/
-
Request: add SEARCH functionalityhttps://wordpress.org/support/topic/request-add-search-functionality/
-
How to add Shortcode?https://wordpress.org/support/topic/how-to-add-shortcode-6/
-
Snippet Suggestionshttps://wordpress.org/support/topic/snippet-suggestions/
-
How to EASILY transfer from Snippets plugin to yours?https://wordpress.org/support/topic/how-to-easily-transfer-from-snippets-plugin-to-yours/
-
How to add and manage tags?https://wordpress.org/support/topic/how-to-add-and-manage-tags/
-
Can a ‘blank’ field/box be added to a category page?https://wordpress.org/support/topic/can-a-bank-field-box-be-added-to-a-category-page/
-
How can I save the sorting by name of all my snippets?https://wordpress.org/support/topic/how-can-i-save-the-sorting-by-name-of-all-my-snippets/
-
How many snippets can I create?https://wordpress.org/support/topic/how-many-snippets-can-i-create/
-
Add Featured Images to RSS Feedshttps://wordpress.org/support/topic/add-featured-images-to-rss-feeds/
-
Ability to duplicate a snippethttps://wordpress.org/support/topic/ability-to-duplicate-a-snippet/
-
API or other way to add programmatically?https://wordpress.org/support/topic/api-or-other-way-to-add-programmatically/
-
Can’t Select Auto-Insert When Creating Custom Code Snippetshttps://wordpress.org/support/topic/cant-select-auto-insert-when-creating-custom-code-snippets/
-
Shortcodes with additional parametershttps://wordpress.org/support/topic/shortcodes-with-additional-parameters/
-
Changing font size of snippethttps://wordpress.org/support/topic/changing-font-size-of-snippet/
-
WPCode across networkhttps://wordpress.org/support/topic/wpcode-across-network/
-
Importing from Code Snippetshttps://wordpress.org/support/topic/importing-from-code-snippets/
-
Custom variables?https://wordpress.org/support/topic/custom-variables-11/
-
Smart content snippet editorhttps://wordpress.org/support/topic/smart-content-snippet-editor/
-
Cloud snippet libraryhttps://wordpress.org/support/topic/cloud-snippet-library/
-
Can’t import JSON snippethttps://wordpress.org/support/topic/cant-import-json-snippet/
-
Can’t choose Shortcodehttps://wordpress.org/support/topic/cant-choose-shortcode/
-
Snippets to change WooCommerce emails – best location?https://wordpress.org/support/topic/snippets-to-change-woocommerce-emails-best-location/
-
Third Party Short Codeshttps://wordpress.org/support/topic/third-party-short-codes-2/
-
Basic Info Notes Fieldhttps://wordpress.org/support/topic/basic-info-notes-field/
-
Tagshttps://wordpress.org/support/topic/tags-133/