📜  css stroke - CSS (1)

📅  最后修改于: 2023-12-03 15:30:08.885000             🧑  作者: Mango

CSS Stroke

In CSS, a stroke refers to the outline or border of a shape or text element. The stroke property can be used to set the color, width, and style of the stroke.

Syntax
selector{
  stroke: color width style;
}
  • color: Specifies the color of the stroke. It can be specified using a keyword or a hexadecimal color value.
  • width: Specifies the width of the stroke in pixels or other length units.
  • style: Specifies the style of the stroke, such as solid, dashed, dotted, double, groove, ridge, inset, or outset.
Examples
Stroke on text
h1{
  stroke: blue 2px solid;
}

This will add a blue stroke around the text of all h1 elements with a width of 2 pixels and a solid style.

Stroke on shapes
div{
  stroke: red 4px dashed;
}

This will add a red stroke around all div elements with a width of 4 pixels and a dashed style.

Different stroke styles
p{
  stroke: green 1px solid;
}

span{
  stroke: orange 2px dotted;
}

a{
  stroke: purple 3px double;
}

This example shows how different stroke styles can be applied to different elements on a page.

Conclusion

Stroke properties in CSS can add visual interest to text and shapes on a webpage. By understanding the syntax and available options for the stroke property, developers can create custom effects to enhance the design of their site.