CSS [attribute] Selector
The [attribute] selector is used to select elements with the specified attribute.
The following example selects all <a> elements with a target attribute:
Example
a[target] {
background-color: yellow;
}
background-color: yellow;
}
CSS [attribute=value] Selector
The [attribute=value] selector is used to select elements with the specified attribute and value.
The following example selects all <a> elements with a target="_blank" attribute:
Example
a[target="_blank"] {
background-color: yellow;
}
background-color: yellow;
}
CSS [attribute~=value] Selector
The [attribute~=value] selector is used to select elements with an attribute value containing a specified word.
The following example selects all elements with a title attribute that contains a space-separated list of words, one of which is "flower":
Example
[title~="flower"] {
border: 5px solid yellow;
}
border: 5px solid yellow;
}
CSS [attribute|=value] Selector
The [attribute|=value] selector is used to select elements with the specified attribute starting with the specified value.
The following example selects all elements with a class attribute value that begins with "top":
Note: The value has to be a whole word, either alone, like class="top", or followed by a hyphen( - ), like class="top-text"!
Example
[class|="top"] {
background: yellow;
}
background: yellow;
}
CSS [attribute^=value] Selector
The [attribute^=value] selector is used to select elements whose attribute value begins with a specified value.
The following example selects all elements with a class attribute value that begins with "top":
Note: The value does not have to be a whole word!
Example
[class^="top"] {
background: yellow;
}
background: yellow;
}
CSS [attribute$=value] Selector
The [attribute$=value] selector is used to select elements whose attribute value ends with a specified value.
The following example selects all elements with a class attribute value that ends with "test":
Note: The value does not has to be a whole word!
Example
[class$="test"] {
background: yellow;
}
background: yellow;
}
CSS [attribute*=value] Selector
The [attribute*=value] selector is used to select elements whose attribute value contains a specified value.
The following example selects all elements with a class attribute value that contains "te":
Note: The value does not has to be a whole word!
Example
[class*="te"] {
background: yellow;
}
background: yellow;
}
Styling Forms
The attribute selectors can be useful for styling forms without class or ID:
Example
input[type="text"] {
width: 150px;
display: block;
margin-bottom: 10px;
background-color: yellow;
}
input[type="button"] {
width: 120px;
margin-left: 35px;
display: block;
}
width: 150px;
display: block;
margin-bottom: 10px;
background-color: yellow;
}
input[type="button"] {
width: 120px;
margin-left: 35px;
display: block;
}
شركة الاول للتنظيف و مكافحة الحشرات شركة الاول للتنظيف و مكافحة الحشرات
ReplyDeleteشركة جلي بلاط بالرياض شركة جلي بلاط بالرياض
افضل شركة تنظيف اثاث بالرياض افضل شركة تنظيف اثاث بالرياض
شركة تنظيف مجالس بالرياض شركة تنظيف مجالس بالرياض
أفضل شركة تنظيف بالقصيم أفضل شركة تنظيف منازل بالقصيم
شركة مكافحة حشرات بالقصيم افضل شركة مكافحة حشرات بالقصيم
شركة صيانة مكيفات بالرياض
شركة عزل الاسطح بالرياض