Languages
[Edit]
EN

JavaScript - fillStyle vs strokeStyle

0 points
Created by:
Kevin
797

In this article, we would like to show you the difference between fillStyle and strokeStyle in JavaScript.

Quick solution:

1. strokeStyle is used for setting the shape outline color,

fillStyle is used for setting the fill color.

Note:

The properties can be set to a string representing a CSS color value, a gradient or a pattern. By default, the strokeStyle and fillStyle colors are set to black.

 

Practical example

Edit

In this section, we present a practical example that shows the difference between strokeStyle and fillStyle properties.

See also

Edit
  1. JavaScript - draw square on canvas element

  2. JavaScript - set line width (thickness) on canvas element

References

Edit
  1. fillStyle - Web APIs | MDN
  2. strokeStyle - Web APIs | MDN

Alternative titles

  1. JavaScript - fillStyle vs strokeStyle (HTML canvas element)
  2. JavaScript - fillStyle and strokeStyle differences
  3. JavaScript - difference between fillStyle and strokeStyle
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

JavaScript - HTML5 canvas tutorial

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join