# EditorContext.format(string name, string value)

> 基础库 2.7.0 开始支持，低版本需做[兼容处理](1003706)。

> __小程序插件__：支持

> 相关文档: [editor 组件](/miniprogram/dev/component/editor.md)

## 功能描述

修改样式

## 参数

### string name

属性

### string value

值

## 支持设置的样式列表
| name                                                      | value                           | verson |
| --------------------------------------------------------- | ------------------------------- | ------ |
| bold                                                      |                                 | 2.7.0  |
| italic                                                    |                                 | 2.7.0  |
| underline                                                 |                                 | 2.7.0  |
| strike                                                    |                                 | 2.7.0  |
| ins                                                       |                                 | 2.7.0  |
| script                                                    | sub / super                     | 2.7.0  |
| header                                                    | H1 / H2 / h3 / H4 / h5 /  H6    | 2.7.0  |
| align                                                     | left / center / right / justify | 2.7.0  |
| direction                                                 | rtl                             | 2.7.0  |
| indent                                                    | -1 / +1                         | 2.7.0  |
| list                                                      | ordered / bullet / check        | 2.7.0  |
| color                                                     | hex color                       | 2.7.0  |
| backgroundColor                                           | hex color                       | 2.7.0  |
| margin/marginTop/marginBottom/marginLeft/marginRight      | css style                       | 2.7.0  |
| padding/paddingTop/paddingBottom/paddingLeft/paddingRight | css style                       | 2.7.0  |
| font/fontSize/fontStyle/fontVariant/fontWeight/fontFamily | css style                       | 2.7.0  |
| lineHeight                                                | css style                       | 2.7.0  |
| letterSpacing                                             | css style                       | 2.7.0  |
| textDecoration                                            | css style                       | 2.7.0  |
| textIndent                                                | css style                       | 2.8.0  |
| wordWrap                                                  | css style                       | 2.10.2 |
| wordBreak                                                 | css style                       | 2.10.2 |
| whiteSpace                                                | css style                       | 2.10.2 |

对已经应用样式的选区设置会取消样式。css style 表示 css 中规定的允许值。
