• Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
logo logo
  • Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
ENEN
  • 简体简体
  • 繁體繁體
Client Area

Css Basic: fill

December 20, 2023

CSS Basics: Fill

CSS (Cascading Style Sheets) is a fundamental technology used for styling web pages. It allows web developers to control the appearance of HTML elements on a website. One of the essential CSS properties is the “fill” property, which is used to specify the color or image used to fill the content of an element.

Understanding the Fill Property

The “fill” property is primarily used with SVG (Scalable Vector Graphics) elements, but it can also be applied to other HTML elements. It determines the color or image that fills the content area of an element, such as a shape or a container.

When using the “fill” property, you can specify the color using various formats, including named colors (e.g., red, blue), hexadecimal values (e.g., #FF0000, #0000FF), RGB values (e.g., rgb(255, 0, 0), rgb(0, 0, 255)), or HSL values (e.g., hsl(0, 100%, 50%), hsl(240, 100%, 50%)).

Here’s an example of how to use the “fill” property to specify a red color:


.shape {
  fill: red;
}

In addition to solid colors, the “fill” property can also accept image values. This allows you to use an image as the fill pattern for an element. You can specify the image URL using the “url()” function.

Here’s an example of how to use the “fill” property with an image:


.shape {
  fill: url("image.jpg");
}

Applying the Fill Property

The “fill” property can be applied to various HTML elements, including SVG shapes, <div> containers, and even text.

For SVG shapes, such as rectangles, circles, or polygons, the “fill” property determines the color or image used to fill the shape’s interior.

Here’s an example of how to apply the “fill” property to an SVG rectangle:


<svg width="200" height="100">
  <rect x="0" y="0" width="200" height="100" class="shape"></rect>
</svg>


.shape {
  fill: blue;
}


For <div> containers, the “fill” property can be used to set the background color or image.

Here’s an example of how to apply the “fill” property to a <div> container:


<div class="container">This is a container</div>


.container {
  fill: yellow;
}


Even text can have its fill color modified using the “fill” property. However, this only applies to SVG text elements.

Here’s an example of how to apply the “fill” property to an SVG text element:


<svg width="200" height="100">
  <text x="0" y="50" class="shape">This is some text</text>
</svg>


.shape {
  fill: green;
}


Conclusion

The “fill” property is a powerful CSS property that allows you to control the color or image used to fill the content of an element. Whether you’re working with SVG shapes, <div> containers, or SVG text elements, the “fill” property provides you with the flexibility to customize the appearance of your web page.

For more information on CSS and web hosting services, consider checking out Server.HK. They offer reliable VPS hosting solutions with top-notch performance and support.

Recent Posts

  • How to Set Up Nginx on CentOS Stream for High-Performance Web Hosting
  • CentOS Stream Explained: Key Differences from CentOS Linux
  • How to Configure FirewallD in CentOS Stream: From Essential to Production-Grade
  • Installing Docker on CentOS: A Practical Setup Guide (CentOS Stream 9/10 – 2026)
  • How to Secure a CentOS Server: 15 Essential Hardening Techniques (CentOS Stream 9/10 – 2026)

Recent Comments

No comments to show.

Knowledge Base

Access detailed guides, tutorials, and resources.

Live Chat

Get instant help 24/7 from our support team.

Send Ticket

Our team typically responds within 10 minutes.

logo
Alipay Cc-paypal Cc-stripe Cc-visa Cc-mastercard Bitcoin
Cloud VPS
  • Hong Kong VPS
  • US VPS
Dedicated Servers
  • Hong Kong Servers
  • US Servers
  • Singapore Servers
  • Japan Servers
More
  • Contact Us
  • Blog
  • Legal
© 2026 Server.HK | Hosting Limited, Hong Kong | Company Registration No. 77008912
Telegram
Telegram @ServerHKBot