# 主要样式表(style.css)
## 话题
* [地点](https://developer.wordpress.org/themes/basics/main-stylesheet-style-css/#location)
* [基本结构](https://developer.wordpress.org/themes/basics/main-stylesheet-style-css/#basic-structure)
* [例子](https://developer.wordpress.org/themes/basics/main-stylesheet-style-css/#example)
* [解释说明](https://developer.wordpress.org/themes/basics/main-stylesheet-style-css/#explanations)
* [子主题的Style.css](https://developer.wordpress.org/themes/basics/main-stylesheet-style-css/#style-css-for-a-child-theme)
style.css是每个WordPress主题所需的样式表(CSS)文件。它控制网站页面的呈现(视觉设计和布局)。
## 位置[编号地点](https://developer.wordpress.org/themes/basics/main-stylesheet-style-css/#location)
为了使WordPress将主题模板文件集识别为有效主题,style.css文件必须位于主题的根目录中,而不是子目录中。
有关如何在主题中包括style.css文件的更多详细说明,请参见“[使脚本和样式](https://developer.wordpress.org/themes/basics/including-css-javascript/#stylesheets)入队”中的“样式表”部分。
[顶部↑](https://developer.wordpress.org/themes/basics/main-stylesheet-style-css/#top)
## 基本结构[#基本结构](https://developer.wordpress.org/themes/basics/main-stylesheet-style-css/#basic-structure)
WordPress使用style.css的标题注释部分在外观(主题)仪表板面板中显示有关主题的信息。
### 例子[#例子](https://developer.wordpress.org/themes/basics/main-stylesheet-style-css/#example)
这是style.css标头部分的示例。
~~~css
/*
Theme Name: Twenty Twenty
Theme URI: https://wordpress.org/themes/twentytwenty/
Author: the WordPress team
Author URI: https://wordpress.org/
Description: Our default theme for 2020 is designed to take full advantage of the flexibility of the block editor. Organizations and businesses have the ability to create dynamic landing pages with endless layouts using the group and column blocks. The centered content column and fine-tuned typography also makes it perfect for traditional blogs. Complete editor styles give you a good idea of what your content will look like, even before you publish. You can give your site a personal touch by changing the background colors and the accent color in the Customizer. The colors of all elements on your site are automatically calculated based on the colors you pick, ensuring a high, accessible color contrast for your visitors.
Tags: blog, one-column, custom-background, custom-colors, custom-logo, custom-menu, editor-style, featured-images, footer-widgets, full-width-template, rtl-language-support, sticky-post, theme-options, threaded-comments, translation-ready, block-styles, wide-blocks, accessibility-ready
Version: 1.3
Requires at least: 5.0
Tested up to: 5.4
Requires PHP: 7.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: twentytwenty
This theme, like WordPress, is licensed under the GPL.
Use it to make something cool, have fun, and share what you've learned with others.
*/
~~~
笔记:WordPress主题存储库使用此文件中“版本”之后的数字来确定主题是否有可用的新版本。
[顶部↑](https://developer.wordpress.org/themes/basics/main-stylesheet-style-css/#top)
### 说明[#解释说明](https://developer.wordpress.org/themes/basics/main-stylesheet-style-css/#explanations)
WordPress主题存储库中的主题需要用(*\**)表示的项目。
* **主题名称**(\*):**主题名称**。
* **主题URI**:公共网页的URL,用户可以在其中找到有关主题的更多信息。
* **作者**(\*):制定主题的个人或组织的名称。建议使用主题作者的wordpress.org用户名。
* **作者URI**:创作个人或组织的URL。
* **说明**(\*):主题的简短说明。
* **版本**(\*):主题的版本,以XX或XXX格式编写。
* **至少需要(\*)**:该主题将使用的最旧的主要WordPress主版本,以XX格式编写。仅需要主题才能支持最后三个版本。
* **经过测试的最高(\*):**主题经过测试的最新主WordPress版本,即5.4。仅以XX格式写数字。
* **需要PHP(\*)**:支持的最旧的PHP版本,以XX格式显示,仅数字
* **许可证**(\*):主题的许可证。
* **许可证URI**(\*):主题许可证的URL。
* **文本域**(\*):用于**文本域**翻译的字符串。
* **标签**:允许用户使用标签过滤器查找主题的单词或短语。标签的完整列表在[主题审查手册中](https://make.wordpress.org/themes/handbook/review/required/theme-tags/)。
* **域路径**:用于禁用主题后,WordPress知道在哪里可以找到译文。默认为`/languages`。
在所需的标头部分之后,style.css可以包含常规CSS文件包含的任何内容。
[顶部↑](https://developer.wordpress.org/themes/basics/main-stylesheet-style-css/#top)
## 子主题的Style.css[#子主题的Style.css](https://developer.wordpress.org/themes/basics/main-stylesheet-style-css/#style-css-for-a-child-theme)
如果您的主题是“子主题”,则style.css标头中必须包含“ **模板”**行。
~~~css
/*
Theme Name: My Child Theme
Template: twentytwenty
*/
~~~
有关创建子主题的更多信息,请访问“[子主题”](https://developer.wordpress.org/themes/advanced-topics/child-themes/)页面。