CSS Rule Anatomy
A CSS rule consists of a selector and a declaration block containing property-value pairs:
/* Selector */
.btn-primary {
/* Declaration: Property: Value; */
background-color: #4f46e5;
color: #ffffff;
padding: 0.75rem 1.5rem;
border-radius: 0.5rem;
border: none;
}
Three Ways to Apply CSS:
- External Stylesheet (
<link rel="stylesheet" href="styles.css">): Recommended production approach. - Internal
<style>Block: Placed inside the document<head>. - Inline
style="..."Attribute: Applied directly to an HTML element (discouraged for scalable design).