Text shadow refers to adding layers to the text, i.e., giving the text a shadow whether to enhance, highlight, or increase the visual appeal of specific text by giving the text depth.
Text shadow can be added to the text by using the tag text-shadow
and defining it within the curly brackets of a particular font style.
The code below shows how to declare it in CSS:
In the above snippet the text-shadow
tag is followed by a semi-colon and 4 arguments, which are as follows:
The x coordinate of the starting point of the shadow
The y coordinate of the starting point of the shadow
The blur radius i.e. how much blurring effect do we want the shadow to have on the text. If you don’t mention this the default value is 0
An optional field which is the color for the text shadow. This must be given in a hexadecimal format
Points to Note:
- The colour field can be written either at the start of the four arguments or at the end
- The coordinate fields can also contain negative values.
- x-coordinate: Positive number means that the shadow will start from that many pixels right of the text and left for negative values.
- y-coordinate: Positive number means that the shadow will start from that many pixels below of the text and above for negative values.
The text-shadow property also allows us to add more than one color of shadow to the text. This is done by simply adding a comma at the end of the first four arguments and adding an additional 4 arguments which will define the properties of the second shadow. You can add multiple shadows this way!
Free Resources