Use the CSS text-shadow property to add a shadow to text, and achieve different effects such as soft shadow, outline or glow by setting the horizontal offset, vertical offset, blur radius and color.
To add a shadow to text in HTML, you use the CSS text-shadow property. This isn't done directly in HTML but through inline styles or CSS rules.
Using Inline Style in HTML
You can apply a text shadow directly on an HTML element using the style attribute:
This text has a shadow
The values ??represent: horizontal offset , vertical offset , blur radius , and color .
CSS Syntax and Values
In a stylesheet, define the text-shadow like this:
h1 {text-shadow: 3px 3px 4px #000;
}
- First value : Horizontal shadow (positive = right, negative = left)
- Second value : Vertical shadow (positive = down, negative = up)
- Third value : Blur radius (larger = more blurred)
- Fourth value (optional) : Shadow color (use hex, RGB, RGBA, or named colors)
Examples of Common Effects
Here are some practical uses:
- Soft shadow :
text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
- Bold outline effect :
text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
- Glow effect :
text-shadow: 0 0 5px #ff0000;
Basically, just set the text-shadow property with the desired offsets, blur, and color. It works on any text element like <h1></h1>
, <p></p>
, or <span></span>
.
The above is the detailed content of how to add a shadow to text in html. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

ArtGPT
AI image generator for creative art from text prompts.

Stock Market GPT
AI powered investment research for smarter decisions

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

1. Go to the official website to download: https://www.consul.io/downloads.html2. Decompression: 3. Set environment variables: path to add E:\programfiles\consul; 4.cmd start: consulagent-dev5. Open the URL: http://localhost:8500, you can see the interface and the interface discovered by related services.

Use single quotes or escaped double quotes to output HTML in PHP. It is recommended to wrap strings with single quotes to avoid attribute quotation conflicts. Dynamic content can be generated in combination with variable splicing or heredoc syntax.

Use the autoplay, muted and playsinline properties to achieve silent automatic playback of HTML videos. Most modern browsers require the video to be muted to play automatically, muted meets this condition, playsinline ensures iOSSafari inline playback instead of full screen, controls are optionally used to display the control bar. If you need to unmute, you can set video.muted=false after user interaction through JavaScript. When triggering programmatically, it must also be set to mute first and catch possible errors. Correctly add these properties and confirm the file path to achieve cross-device compatible silent automatic playback.

Usetype="tel"inHTMLinputtocreateatelephonefield,whichoptimizesmobilekeyboardsandimprovesuserexperience;enhanceitwithattributeslikepattern,required,maxlength,andautocompleteforvalidationandusability.

id is used to uniquely identify a single element, class can be used repeatedly for multiple elements; # select id and . select class in CSS, JavaScript uses getElementById or getElementsByClassName; id is suitable for unique components or anchor links, class is suitable for multiplexing styles or batch operations.

Use Flexbox, inline-block or Grid to display HTML elements side by side: 1. Flexbox is the most recommended, implemented through display:flex; 2. Inline-block should pay attention to the blank spacing; 3. Grid is suitable for complex layouts, and use grid-template-columns to define columns.

To add a border to an HTML table, use the CSS border property and set border-collapse:collapse. First create a table structure containing th and td elements, and then add 1pxsolidblack and other border styles to the table, th, and td through inline, internal or external CSS. It is recommended to use internal CSS to uniformly control the style to ensure a clean and consistent appearance of the table.

Theviewportmetatagensuresproperdisplayonmobiledevicesbysettingwidth=device-widthandinitial-scale=1.0,preventingtiny,unreadablecontentandenablingresponsivedesignforbetterusabilityacrossscreens.
