gpt-4o-mini-2024-07-18· OpenAI
WildChat-4.8M (AI2)
html span color
- User
html span color
- Assistant
In HTML, you can change the color of text within a
<span>element using CSS. Here are a few ways to do this:Inline CSS
You can apply the style directly to the
<span>using thestyleattribute:<span style="color: red;">This text is red.</span>Internal CSS
You can define the style in a
<style>block within the<head>section of your HTML document:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Span Color Example</title> <style> .highlight { color: blue; } </style> </head> <body> <span class="highlight">This text is blue.</span> </body> </html>