The style.css file in a WordPress theme holds the theme's main styles and important information about the theme. This information helps WordPress recognize and display the theme details in the dashboard.
Style.css and theme metadata in Wordpress
/* Theme Name: Your Theme Name Theme URI: http://example.com/your-theme Author: Your Name Author URI: http://example.com Description: A short description of your theme. Version: 1.0 License: GNU General Public License v2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html Text Domain: your-theme-textdomain Tags: light, two-columns, responsive-layout */ /* Your CSS styles start here */
style.css file inside a CSS comment block.Theme Name followed by a colon and the value./*
Theme Name: Simple Blog
Author: Jane Doe
Version: 1.0
Description: A clean and simple blog theme.
*//*
Theme Name: Modern Portfolio
Theme URI: https://example.com/modern-portfolio
Author: John Smith
Author URI: https://example.com
Description: A modern portfolio theme with responsive design.
Version: 2.3
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: modern-portfolio
Tags: portfolio, responsive, grid-layout
*/This style.css file starts with the required theme metadata so WordPress can identify the theme. Below it, simple CSS styles set the font, background, and heading color.
/* Theme Name: Friendly Theme Theme URI: https://friendlytheme.example Author: Friendly Dev Author URI: https://friendlydev.example Description: A warm and welcoming WordPress theme. Version: 1.0 License: GNU General Public License v2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html Text Domain: friendly-theme Tags: friendly, clean, accessible */ body { font-family: Arial, sans-serif; background-color: #f9f9f9; color: #333333; } h1 { color: #2a7ae2; }
Always keep the metadata block at the top of style.css for WordPress to read it correctly.
Use meaningful and accurate information in the metadata to help users understand your theme.
The Text Domain is important for translations and should match your theme folder name.
The style.css file holds both the theme's styles and its metadata.
The metadata block tells WordPress the theme's name, author, version, and more.
Proper metadata helps WordPress list and manage your theme correctly.
Practice
style.css file in a WordPress theme?Solution
Step 1: Understand the role of style.css
Thestyle.cssfile contains CSS styles that define the look of the theme.Step 2: Recognize the metadata block
It also includes a metadata comment block that tells WordPress about the theme's name, author, and version.Final Answer:
To hold the theme's styles and metadata information -> Option DQuick Check:
style.css = styles + metadata [OK]
- Confusing style.css with functions.php
- Thinking style.css manages database or users
- Ignoring the metadata block in style.css
style.css for a WordPress theme?Solution
Step 1: Identify CSS comment syntax
CSS comments use/* ... */to enclose text, including metadata.Step 2: Check WordPress metadata format
WordPress expects metadata in a CSS comment block at the top ofstyle.css.Final Answer:
/*\nTheme Name: My Theme\n*/ -> Option AQuick Check:
Metadata uses CSS comments /* ... */ [OK]
- Using // or # which are not CSS comments
- Using HTML comments in CSS
- Placing metadata outside comment block
style.css, what is the theme's version?/* Theme Name: Simple Theme Author: Jane Doe Version: 1.2.3 */
Solution
Step 1: Locate the Version field
Within the metadata block, the line starting with 'Version:' shows the theme's version number.Step 2: Read the version value
The version is '1.2.3' as given after 'Version:'.Final Answer:
1.2.3 -> Option BQuick Check:
Version field = 1.2.3 [OK]
- Confusing Author with Version
- Picking Theme Name as version
- Ignoring the metadata block format
style.css that prevents WordPress from recognizing the theme?/* Theme-Name: Cool Theme Author: John Smith Version: 2.0 */
Solution
Step 1: Check metadata field names
WordPress requires exact field names like 'Theme Name' with a space, not 'Theme-Name'.Step 2: Verify comment block correctness
The comment block is properly opened and closed with /* and */.Final Answer:
The field 'Theme-Name' should be 'Theme Name' without a dash -> Option AQuick Check:
Field names must match exactly [OK]
- Using dashes instead of spaces in field names
- Leaving comment block unclosed
- Misunderstanding version format rules
style.css to link it to the parent theme?Solution
Step 1: Understand child theme metadata
To link a child theme to its parent, WordPress uses the 'Template' field with the parent's folder name.Step 2: Identify correct field name
The correct metadata field is 'Template', not 'Parent', 'Inherits', or 'Depends-On'.Final Answer:
Template: parent-theme-folder-name -> Option CQuick Check:
Child theme uses Template field to link parent [OK]
- Using 'Parent' instead of 'Template'
- Confusing theme name with folder name
- Omitting the Template field in child theme
Ready to prove it?
Pass the test and this pattern moves unknown
