Introduction
Curved text adds visual interest and creative flair to web designs, from decorative headlines to circular logos and animated effects. Modern web development offers two primary approaches: SVG textPath for static curved text and CSS Motion Path for animated effects. These techniques are essential tools for frontend developers building visually engaging interfaces.
This guide covers both SVG and CSS approaches with practical examples, best practices, and performance considerations. Whether you're building a custom website or enhancing an existing project, curved text effects can elevate your design system and create memorable user experiences. Strategic use of visual effects also contributes to improved user engagement metrics that search engines consider in rankings.
Understanding the Two Approaches
Modern browsers support two distinct methods for creating curved text: SVG textPath for static text that follows a path, and CSS Motion Path for animating elements along curved trajectories. Understanding when to use each approach is essential for building performant, maintainable web interfaces.
SVG textPath excels at creating static curved text that renders crisply at any size and is accessible to screen readers. CSS Motion Path is designed primarily for animation but can position elements along paths with smooth transitions. The right choice depends on your use case--whether you need a decorative logo element or an interactive scroll effect.
For professional web development services, mastering both techniques ensures you can choose the optimal solution for each design requirement.
SVG textPath Method
The SVG textPath method uses three built-in SVG elements to create curved text:
<path>- defines the curved line that text will follow<text>- contains the text content<textPath>- links the text to the path, making the text conform to the path's shape
This approach creates text that inherently follows the curvature of the defined path, making it ideal for logos, decorative headlines, and circular text effects. The SVG approach is widely supported and renders consistently across all modern browsers, making it a reliable choice for production websites built with modern web technologies. For more on working with SVG graphics, see our SVG Graphics Mastery guide.
1<svg viewBox="0 0 500 200">2 <path id="curve" d="M10,100 Q100,10 200,100 T400,100" fill="transparent"/>3 <text width="500">4 <textPath href="#curve" startOffset="50%" text-anchor="middle">5 Curved Text Along a Path6 </textPath>7 </text>8</svg>Essential textPath Attributes
| Attribute | Purpose | Values |
|---|---|---|
href | References the path element | URL reference (e.g., #curve) |
startOffset | Distance along path where text begins | Percentage or absolute value |
text-anchor | Horizontal alignment | start, middle, end |
method | Glyph rendering method | align (default), stretch |
spacing | Letter spacing behavior | exact (default), auto |
side | Which side of path text appears | left (default), right |
As documented in the MDN Web Docs textPath reference, these attributes provide fine-grained control over text positioning and appearance along curved paths.
Understanding the Path d Attribute
The d attribute defines the shape of the path using a series of commands and coordinates. According to Smashing Magazine's guide to SVG paths, these commands give you precise control over curve geometry:
- M (Move To) - Moves the pen to a starting position without drawing
- Q (Quadratic Bezier) - Creates a curve with one control point
- T (Smooth Quadratic Bezier) - Continues a smooth curve from the previous control point
- C (Cubic Bezier) - Creates a curve with two control points for complex curves
- A (Arc) - Creates circular or elliptical arcs for circular text
- Z (Close Path) - Draws a straight line back to the starting point
For text along paths, quadratic (Q/T) and cubic (C) Bezier curves are most commonly used because they provide smooth, predictable curvature that works well for readable text.
Circular and Arc Text
Circular text is a popular use case for curved text, often seen in badges, logos, and decorative elements. Creating circular text requires an arc-based path. The CSS-Tricks curved text snippet provides a reliable pattern for circular text implementation:
1<svg viewBox="0 0 200 200">2 <path id="circle"3 d="M100,100 m-80,0 a80,80 0 1,0 160,0 a80,80 0 1,0 -160,0"4 fill="transparent"/>5 <text>6 <textPath href="#circle" startOffset="0%" text-anchor="start">7 Circular Text Example8 </textPath>9 </text>10</svg>The a command creates elliptical arcs with parameters for:
- rx, ry: Radii of the ellipse (both 80 for a perfect circle)
- x-axis-rotation: Rotation angle of the ellipse
- large-arc-flag: 0 or 1 (determines which arc to use when there are two possibilities)
- sweep-flag: 0 or 1 (arc direction--clockwise or counterclockwise)
- x, y: Endpoint coordinates of the arc
For complete circular text that wraps around, you'll need two arc commands--one for each half of the circle.
CSS Motion Path for Curved Effects
CSS Motion Path, part of the CSS Offset Module Level 1 as documented on MDN Web Docs, provides a declarative way to animate elements along custom paths using pure CSS properties:
offset-path- Defines the path using CSSpath()function or SVG referenceoffset-distance- Controls position along the path (0% to 100%)offset-rotate- Controls element orientation relative to the path direction
This approach is particularly useful for animated effects where elements need to follow curved trajectories, such as particles following a wave pattern or UI elements that trace a path during interactions. When combined with strategic animation techniques, you can create sophisticated motion graphics that enhance user engagement.
1.curved-element {2 offset-path: path('M10,100 Q100,10 200,100 T400,100');3 offset-distance: 0%;4 animation: moveAlongPath 3s ease-in-out infinite alternate;5}6 7@keyframes moveAlongPath {8 to { offset-distance: 100%; }9}Pure CSS Circular Text Technique
For projects where SVG markup isn't desirable, a pure CSS approach can create circular text using transforms and perspective. As detailed in the Frontend Masters technique guide, this method uses three key steps:
Step 1: Splitting - Text is split into multiple span elements with index variables (CSS custom properties) Step 2: Positioning - CSS transforms position each segment around a circle using rotation and translation Step 3: Perspective - Perspective creates the 3D effect for seamless text appearance
This technique works without any JavaScript and can be implemented entirely in your stylesheet, making it a lightweight alternative for projects that prefer minimal markup. This approach is particularly valuable when building performance-optimized websites where minimizing JavaScript overhead is a priority.
1.textContainer {2 perspective: 15em;3}4 5.textContainer span {6 position: absolute;7 transform:8 translate(-50%, -50%)9 rotate(calc(15deg * var(--i)))10 translateY(calc(-1em / sin(15deg)))11 rotateX(-90deg);12}Animating Curved Text
Animated curved text creates engaging user experiences and can draw attention to important content. Two main approaches are commonly used:
JavaScript Scroll Animation
Adjust the startOffset attribute based on scroll position for scroll-linked effects that respond to user interaction. The CSS-Tricks guide to moving text on curved paths demonstrates this scroll-driven animation technique:
const textPath = document.querySelector("#text-path");
document.addEventListener("scroll", () => {
const percent = window.scrollY / (document.body.scrollHeight - window.innerHeight);
textPath.setAttribute("startOffset", (-percent * 40) + 1200);
});
This approach creates effects where text appears to reveal itself along a curve as users scroll, adding visual interest to long-form content pages.
CSS Keyframe Animation
For continuous animations, use CSS keyframes with offset-distance for smooth, performant motion along paths without JavaScript overhead.
Accessibility Considerations
When implementing curved text, accessibility should be a primary concern to ensure your website is usable by everyone:
Screen Reader Support
SVG text is generally accessible to screen readers, but ensure content is readable in linear order. Add title and desc elements within the SVG to provide context. For decorative curved text that isn't essential content, consider using aria-hidden="true" and providing a visually hidden text alternative.
Reduced Motion
Respect user preferences using prefers-reduced-motion media query. Users who experience discomfort from motion should have the option to disable animated curved text:
@media (prefers-reduced-motion: reduce) {
.animated-curved-text {
animation: none;
offset-distance: 50%;
}
}
Alternative Content
Provide plain text alternatives for decorative curved text using aria-label or aria-describedby to ensure screen reader users receive the same information as visual users.
Following web accessibility guidelines ensures your curved text effects don't exclude users with disabilities. Implementing accessible design practices also supports better SEO performance as search engines increasingly prioritize accessible websites.
Performance Best Practices
- Use SVG textPath for static text - More performant than JavaScript alternatives and renders efficiently in the browser's graphics layer
- Cache SVG references - Store paths in
<defs>and use<use>to reference them, reducing markup duplication - Limit path complexity - Simple Bezier curves (2-3 segments) perform better than complex multi-segment paths
- Use
will-changesparingly - Only apply to elements that will actually animate, as it can increase memory usage
Browser Compatibility
SVG textPath has excellent browser support, achieving Baseline status since 2015 according to caniuse.com data. CSS Motion Path has good support in modern browsers but may require fallbacks for older browsers. Always test your curved text implementations across target browsers and consider progressive enhancement for the widest compatibility.
For optimal website performance, implement these techniques with proper fallbacks and test thoroughly before deployment.
CSS Animation Fundamentals
Master CSS animations and transitions for dynamic web interfaces.
Learn moreSVG Graphics Mastery
Create scalable vector graphics for crisp, resolution-independent visuals.
Learn moreInteractive UI Patterns
Build engaging user interfaces with modern interaction techniques.
Learn moreSources
- MDN Web Docs - textPath Element - Complete SVG textPath reference with all attributes and examples
- MDN Web Docs - CSS Motion Path - CSS offset-path properties and usage documentation
- Frontend Masters - Pure CSS Circular Text - Step-by-step CSS-only circular text technique using perspective transforms
- CSS-Tricks - Moving Text on a Curved Path - Scroll-linked animation technique with SVG textPath
- CSS-Tricks - Curved Text Along a Path - Comprehensive SVG textPath tutorial with code examples
- Smashing Magazine - Decoding SVG Path Element - In-depth guide on curve and arc commands