The fourth value sets the base color of the shadow.A larger value produces a more fuzzy-looking shadow. The third pixel value sets the blur radius of the shadow.The second pixel value sets the vertical offset of the shadow from the text: how far it moves down.The first pixel value sets the horizontal offset of the shadow from the text: how far it moves across.Next, we set the heading's top and bottom padding to 20 pixels.įollowing that, we set the heading text to be the same color as the HTML background color.įinally, text-shadow applies a shadow to the text content of the element. To eliminate the gap, we overwrite the browser's default styling with the setting margin: 0. That might seem like a bad idea, but the intent is to provide basic readability for unstyled pages. That happens because browsers apply default styling to the element (among others). You may have noticed there's a horrible gap at the top of the body. Apart from the selector, each ruleset must be wrapped in curly braces.Note the other important parts of the syntax: (For example, there are many color values in addition to red.) This chooses one out of many possible appearances for a given property. To the right of the property-after the colon-there is the property value. I'm on a Mac using Chrome 11, Safari 5 and Firefox 5. However, the colours are rendered without problems on Safari and Firefox. For example, FFAF00 is rendered as FFA400 according to the Color Meter. (In this example, color is a property of the elements.) In CSS, you choose which properties you want to affect in the rule. The colour that the Color Meter reports (and what I see) differs from what CSS says. These are ways in which you can style an HTML element. It specifies which of the element's properties you want to style. To style a different element, change the selector. It defines the element(s) to be styled (in this example, elements). This is the HTML element name at the start of the ruleset. (The term ruleset is often referred to as just rule.) Note the names of the individual parts: Selector
Let's dissect the CSS code for red paragraph text to understand how it works :