• 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-rule

December 20, 2023

CSS Basics: fill-rule

CSS (Cascading Style Sheets) is a fundamental technology used for styling web pages. It allows developers to control the appearance of HTML elements, including colors, fonts, layouts, and more. One important CSS property is fill-rule, which determines how the interior of a shape is filled.

Understanding fill-rule

When working with SVG (Scalable Vector Graphics) or other vector-based graphics, shapes can overlap or intersect. The fill-rule property specifies how the browser determines which parts of the shape to fill and which parts to leave empty.

The fill-rule property accepts two values:

  • nonzero: This is the default value. It means that the browser fills any area that is crossed by the shape’s outline an odd number of times.
  • evenodd: With this value, the browser fills any area that is crossed by the shape’s outline an odd number of times with a solid color, and any area crossed an even number of times remains empty.

Examples

Let’s take a look at some examples to understand how fill-rule works:

<svg width="200" height="200">
  <path d="M50 50 L150 50 L150 150 L50 150 Z" fill="red" fill-rule="nonzero" />
</svg>

In this example, we have a square shape defined by four lines. The fill-rule is set to nonzero. As a result, the entire area inside the shape is filled with the color red.

<svg width="200" height="200">
  <path d="M50 50 L150 50 L150 150 L50 150 Z" fill="blue" fill-rule="evenodd" />
</svg>

In this second example, we have the same square shape, but the fill-rule is set to evenodd. As a result, only the area inside the shape that is crossed an odd number of times by the outline is filled with the color blue. The area crossed an even number of times remains empty.

Conclusion

The fill-rule property in CSS is a powerful tool for controlling how shapes are filled in SVG and other vector-based graphics. By understanding the two available values, nonzero and evenodd, developers can create visually appealing and precise designs.

Learn More About Server.HK

If you are interested in VPS hosting services, Server.HK offers top-notch solutions. With reliable servers and excellent customer support, Server.HK is a trusted provider in the industry. Visit the Server.HK website to learn more about their hosting plans and features.

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