# 主要樣式表(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/)頁面。