Set the color property of all <p> elements:
The css() method sets or returns one or more style properties for the selected elements.
When used to return properties:
This method returns the specified CSS property
value of the FIRST matched element.
However, shorthand CSS properties (like "background" and "border") are not
fully supported and may give different results in different browsers,
when used to return property values.
When used to set properties:
This method sets the specified CSS property
for ALL matched elements.
Return the CSS property value:
Set the CSS property and value:
Set CSS property and value using a function:
Set multiple properties and values:
| Parameter | Description |
|---|---|
| property | Specifies the CSS property name, like "color", "font-weight", etc. |
| value | Specifies the value of the CSS property, like "red", "bold",
etc. |
| function(index,currentvalue) | Specifies a function that returns the new value for the CSS property
|
Return CSS
property value
Return the specified CSS property value of the FIRST matched element.
Set
CSS property and value using a function
Using a function to change a CSS property for the selected elements.
Set
multiple CSS properties and value pairs
How to set multiple CSS properties and values for the selected elements.
The perfect solution for professionals who need to balance work, family, and career building.
More than 10 000 certificates already issued!
The HTML Certificate documents your knowledge of HTML.
The HTML5 Certificate documents your knowledge of advanced HTML5.
The CSS Certificate documents your knowledge of advanced CSS.
The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.
The jQuery Certificate documents your knowledge of jQuery.
The XML Certificate documents your knowledge of XML, XML DOM and XSLT.
The ASP Certificate documents your knowledge of ASP, SQL, and ADO.
The PHP Certificate documents your knowledge of PHP and SQL (MySQL).
Your message has been sent to W3Schools.