header-logo

CODE WITH FAHIM

CSS Outline & Shadows


#CSS Outline Properties:

The CSS outline property is used to draw a line around an element, outside of its border, without affecting the element's size or the overall document layout.

It's primarily used for accessibility, specifically to indicate the focus state of interactive elements (like links, buttons, and form fields) when a user navigates with a keyboard.

✔️ Key points:



#🛠️ Shorthand and Properties:

The outline property is a shorthand for three individual properties. The outline-style is mandatory for the outline to be visible.



#Basic Syntax:
a:focus { outline: 3px solid #ff9900; /* width | style | color */ outline-offset: 2px; /* Adds 2px of transparent space */ }


Property & values:
Property Description
outline-color Sets the outline color
outline-style solid,dashed,dotted etc.
outline-width thickness(in px,%,em,rem etc.)
outline-offset Space between the border and outline


Example:
<style> /* Button gets an outline when focused or clicked */ button:focus { outline: 3px solid #4a90e2; } /* Div shows outline on hover */ .box { width: 200px; height: 80px; background: #f0f0f0; border: 2px solid #888; } .box:hover { outline: 4px dashed red; outline-offset: 5px; } </style> <p>Click the button or hover the box:</p> <button>Focus me!</button> <div class="box"> Hover over me! </div>


Output:

Click the button or hover the box:

Hover over me!




#CSS Shadows:

In CSS, shadows are visual effects that create a sense of depth by adding blurred or offset shading to elements or text. There are two main types:

1.Box-Shadow:

box-shadow is a CSS property that adds shadow effects around an element’s box—such as <div>, <button>, <img> and more. It can create soft, sharp, inner, or multiple shadows.

✅ Basic Syntax:
box-shadow: offset-x offset-y blur-radius spread-radius color inset;


Only offset-x and offset-y are required.Rest are optional.



Example:
<style> .card { width: 250px; height: 120px; background: red; padding: 20px; border-radius: 8px; box-shadow: 25px 25px 25px rgba(72, 187, 18, 0.3); } </style> <div class="card"> This box has a shadow. </div>


Output:
This box has a shadow.


#Multiple box-shadows:

You can apply multiple shadows to the same element using comma-separated box-shadow values. Each shadow is rendered in order (first = bottom layer, last = top layer).
<style> .card { width: 260px; padding: 20px; background: white; border-radius: 10px; box-shadow: 0 6px 12px rgba(0,0,0,0.25), /* main drop shadow */ 0 0 12px rgba(0,150,255,0.5), /* blue outer glow */ inset 0 3px 6px rgba(0,0,0,0.2); /* inner soft shadow */ } </style> <div class="card"> This box has multiple shadows. </div>


Output:
This box has multiple shadows.


2.Text-Shadow:

text-shadow is a CSS property that adds shadows behind text. You can use it to create depth, glow, neon effects, outlines, and more.
✅ Basic Syntax text-shadow: offset-x offset-y blur-radius color;


Only offset-x and offset-y are required.

Same as box shadow....

Example:
<style> .neon { font-size: 70px; font-weight: bold; color: #0ff; text-shadow: 0 0 5px #0ff, 0 0 10px #0ff, 0 0 20px #0ff, 0 0 40px #0ff, 0 0 80px #0ff; } </style> <p class="neon">NEON TEXT</p> </div>
Output:

NEON TEXT

<style> .threeD{text-shadow: 3px 3px 0 #333, 6px 6px 0 #666, 9px 9px 0 #999;} </style> <p class="threeD">3D TEXT</p>
Output:

3D TEXT