Backgrounds and Borders
🎨 Backgrounds and Borders In CSS, backgrounds and borders are used to visually style elements and give your web pages structure and aesthetics. 🔲 Background Properties CSS allows you to control the background of an element using several properties: selector { background-color : #f0f0f0 ; /* Sets background color */ background-image : url ( 'image.jpg' ); /* Sets background image */ background-repeat : no-repeat; /* Prevents image from repeating */ background-position : center center; /* Positions background */ background-size : cover; /* Scales image to cover element */ background-attachment : fixed; /* Fixes background when scrolling */ } Shorthand: background : #f0f0f0 url ( 'image.jpg' ) no-repeat center center / cover fixed; 🧱 Border Properties CSS borders add lines around elements. selector { border-width : 2px ; /* Thickness */ border-style ...