Styles

Styles render, or make available, geospatial data. Styles for GeoServer are written in Styled Layer Descriptor (SLD), a subset of XML. Please see the section on Styling for more information on working with styles.

On the Styles page, you can add a new style, view or edit an existing style, or remove a style.

../../_images/data_style1.png

Styles page

Edit a Style

To view or edit a style, click the style name. A Style Editor page will be diplayed. The page presents options for configuring a style’s name, code, and other attributes. Style names are specified at the top in the name field. The style’s workspace can be chosen using workspace selector. Styles are edited using a plain text editor with some basic utilities.

../../_images/data_style_editor.png

Style editor

The style editor supports line numbering, automatic indentation, and real-time syntax highlighting. You can also increase or decrease the font size of the editor.

Button Description
../../_images/data_style_editor_undo.png undo
../../_images/data_style_editor_redo.png redo
../../_images/data_style_editor_goto.png go to line
../../_images/data_style_editor_reformat.png auto-format the editor contents
../../_images/data_style_editor_fontsize.png change the font size of the editor

To confirm that the SLD code is fully compliant with the SLD schema, click the Validate button. A message box will confirm whether the style contains validation errors.

Note

GeoServer will sometimes render styles that fail validation, but this is not recommended.

../../_images/data_style_editor_noerrors.png

No validation errors

../../_images/data_style_editor_error.png

Validation error message

To view the generated legend entry for the style, click the Preview Legend button.

Add a Style

The buttons for adding and removing a style can be found at the top of the Styles page.

../../_images/data_style_add_delete.png

Adding or removing a style

To add a new style, select the Add a new style button. You will be redirected to an editor page. Enter a name for the style. You can also select the style format. In a default GeoServer installation only SLD is supported, but other extensions (such as css) add support for additional formats. The editor page provides several options for submitting a new style. You can paste the style directly into the editor contents. You can generate a new default style based on an internal template:

../../_images/data_style_editor_generate.png

Generating a new default style.

You can copy the contents of an existing style into the editor:

../../_images/data_style_editor_copy.png

Copying an existing Style from GeoServer

You can select and upload a local file that contains the SLD:

../../_images/data_style_upload.png

Uploading an SLD file from your local computer

Once a style is successfully submitted, you will be redirected to the main Styles page where the new style will be listed.

Remove a Style

To remove a style, select it by clicking the checkbox next to the style. Multiple styles can be selected, or all can be selected by clicking the checkbox in the header. Click the Remove selected style(s) link at the top of the page. You will be asked to confirm or cancel the removal. Clicking OK removes the selected style(s).

../../_images/data_style_delete.png

Confirmation prompt for removing styles