Consider the following example −
body > p { color: #000000; }
This rule will render all the paragraphs in black if they are direct child of <body> element. Other paragraphs put inside other elements like <div> or <td> would not have any effect of this rule.
You can also apply styles to HTML elements with particular attributes. The style rule below will match all the input elements having a type attribute with a value of text −
input[type = "text"]{ color: #000000; }
The advantage to this method is that the <input type = "submit" /> element is unaffected, and the color applied only to the desired text fields.
p[lang] : Selects all paragraph elements with a lang attribute.
p[lang="fr"] - Selects all paragraph elements whose lang attribute has a value of exactly "fr".
p[lang~="fr"] - Selects all paragraph elements whose lang attribute contains the word "fr".
p[lang|="en"] - Selects all paragraph elements whose lang attribute contains values that are exactly "en", or begin with "en-".
There are four ways to associate styles with your HTML document. Most commonly used methods are inline CSS and External CSS.
- Embedded CSS − The <style> Element: You can put your CSS rules into an HTML document using the <style> element.
- Inline CSS − The style Attribute: You can use style attribute of any HTML element to define style rules.
- External CSS − The <link> Element: The <link> element can be used to include an external stylesheet file in your HTML document.
- Imported CSS − @import Rule: @import is used to import an external stylesheet in a manner similar to the <link> element.
Following is the rule to override any Style Sheet Rule −
- Any inline style sheet takes highest priority. So, it will override any rule defined in <style>...</style> tags or rules defined in any external style sheet file.
- Any rule defined in <style>...</style> tags will override rules defined in any external style sheet file.
- Any rule defined in external style sheet file takes lowest priority, and rules defined in this file will be applied only when above two rules are not applicable.
No comments:
Post a Comment