The :focus pseudo-class is used to apply styles to an element when it has keyboard focus, typically on form elements like input fields.