Wednesday, August 14, 2019
Html Studyguide
The general syntax of a CSS style rule is selector { property1: value1; property2: value2; property3: value3; } Order in which style sheets are interpreted. The more specific style is applied instead of the more general. 1. 2. 3. 4. 5. Browserââ¬â¢s internal style sheet User-defined style sheet Authorââ¬â¢s external style sheet Authorââ¬â¢s embedded style sheet Authorââ¬â¢s inline style sheet User-Defined Styles Almost all browsers allow users to modify the default settings of the internal style sheet. External Style SheetsTo link to an external style sheet use the following text directly above the closing head text tag: Embedded Style Sheets Styles are inserted directly within the head element of an HTML document using the style element: styles Or h1 {Color: red; Text-align: center;} The order in which external and embedded style sheets are processed depends on the order in which they are listed within the HTML file. In the below example the loads the external style sheet first and then the embedded SS. If the order were switched the imported SS gets processed after the embedded one. h1 {Color: red; Text-align: center;} Inline Styles Applied directly to specific elements using the style attribute: â⬠¦ Importing Style Sheets To import a style sheet to a master style sheet use the @import statement BEFORE any other style rules: @import url(url); or for example @import url(sa_styles. css); Exploring the Style Cascade As a general rule of thumb, all other things being equal, the more specific style is applied instead of the more general . An additional factor in applying a style sheet is that properties are passed from a parent element to its children in a process known as style inheritance. body {color: blue;} h1 {text-align: center;} If you need browsers to enforce a style, you can append the ! important keyword to the style property, using the syntax: property: value ! mportant; Defining Color in CSS A color value is a numerical expression that describes the properties of a color CSS represents these intensities mathematically as a set of numbers called an RGB triplet, which has the format color: rgb(red, green, blue); color:#redgreenblue ; background-color: color; color: color; or or or or color: rgb(255,255,0); color:#FFFF00; background-color: rgb(255,255,0); or color:#FFFF00; or color:white; CSS also allows RGB values to be entered as hexadecimal numbers To set th e background color of an element, use the below property where color is a color name or a color value. To set the foreground or text color of an element, use the following property: color: rgb(255,255,0); or or CSS3 also supports the Hue Saturation Lightness (HSL) model that describes colors based on hue, saturation, and lightness hsl(hue, saturation, lightness) rgba(red, green, blue, opacity) hsl(360, 100%, 100%) rgba(255, 255, 255, 0. 8) hsla(360, 100%, 100%, 0. 2) CSS3 also allows page designers to augment RGB and HSL color with opacity where 0 = completely transparent and 1 = completely opaque. hsla(hue, saturation, lightness, opacity) or Selectors and Text Styles Web pages are structured documents in which elements are nested within other elements, forming a hierarchy of elements. To create styles that take advantage of this tree structure, CSS allows you to create contextual selectors whose values represent the locations of elements within the hierarchy: 1) 2) 3) 4) Parent elements Child elements Sibling elements Descendant elements Contextual Selectors Attribute Selectors Selectors also can be defined based on attributes and attribute values associated with elements. Two attributes, id and class, are often key in targeting styles to a specific element or group of elements. Styling Web Page Text The default font used by most browsers is Times New Roman, but you can specify a different font for any page element using the property: font-family: fonts; or font-family: ââ¬ËArial Blackââ¬â¢, gadget, sans-serif; Setting Font Face and Sizes: Sizes can be relative or absolute. To define a font face, use the style property: font-family: fonts; font-size: size; letter-spacing: size; word-spacing: size; To specify the font style, use the below style where type is normal, italic, or oblique. ont-style: type; To specify the font weight, use the below format where type is normal, bold, bolder, light, lighter, or a font weight value. font-weight: type; To specify a text decoration, use the below format where type is none, underline, overline, or line-through. text-decoration: type; To transform text, use the below code where type is capitalize, uppercase, lowercase, or none. text-transform: type; To display a font variant of text, use the below format where type is normal or small-caps. ont-variant: type; You can combine most of the text and font styles into a single property using the shortcut font property font: font-style font-variant font-weight font-size/line-height font-family; Combining Text Format in a single style or or or font-family: ââ¬ËArial Blackââ¬â¢, gadget, sans-serif; font-size: 0. 5in; or font-size: 36pt; font-size: 0. 5in; or font-size: 3pc; or font-size: 1. 7em; To set a font size, use the below style property where size is a CSS unit of length in either relative or absolute units. To set kerning (the space between letters), use the following style property: To set tracking (the space between words), use the following style property: Designing a List To define the appearance of the list marker, use the style below where type is disc, circle, square, decimal, decimal-leading-zero, lower-roman, upper-roman, lower-alpha, upper-alpha, lower-greek, upper-greek, or none. list-style-type: type; To insert a graphic image as a list marker, use the style below where url is the URL of the graphic image file. ist-style-image: url(url); To set the position of list markers, use the style below where position is inside or outside. list-style-position: position; To define all of the list style properties in a single style, use the following style: list-style: type url(url) position; To set the indentation of a list, apply the style below where size is the length that the list should be indented. padding-left: size; Using Pseudo-Classes and Pseudo-Elements A pseudo-class is a c lassification of an element based on its current status, position, or use in the document selector:pseudo-class {styles;} Structural Psuedo Classes
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.