css() MethodThe css() method in jQuery allows you to dynamically get or set CSS style properties of selected elements.
// Set a single CSS property
$(selector).css("property","value");
// Set multiple CSS properties
$(selector).css({"property1":"value1","property2":"value2"});
// Get a CSS property value
$(selector).css("property");
// Increase font size dynamically
$('#secondBox').css('font-size','24px');
// Apply dashed green border
$('#secondBox').css('border','3px dashed green');
Adjust the controls below to see css() applied instantly to the box.
Buttons above dynamically change text color, background, font size, and borders using the css() method.
css() for dynamic styling based on user interactioncss() for responsive logiccss()