CSS CSS Tutorial CSS Advanced CSS Responsive Web Design(RWD) CSS Grid CSS Properties Sass Tutorial Sass Functions



CSS Outline

CSS Outline is a property that allows you to add an outline around an HTML element. It is similar to the border property, but it is not a part of the box model. The outline property is used to highlight an element, and it is often used to indicate focus on an element, such as when a user clicks on a link or a form field.

The outline property can be used to create a variety of effects, such as dashed or dotted lines, and it can be customized with different colors and widths. The outline property can also be used to create a 3D effect by using multiple outlines with different colors and widths.

Here are some examples of how to use the outline property:

  <p style="outline: 1px solid red;">This is a paragraph with a red outline.</p>
  <div style="outline: 2px dashed blue;">This is a div with a blue dashed outline.</div>
  <button style="outline: 3px double green;">Click me</button>

In the examples above, we have used the outline property to add an outline to a paragraph, a div, and a button. We have also used different styles for the outline, such as solid, dashed, and double, and different colors, such as red, blue, and green.

The outline property can also be used with the :focus pseudo-class to indicate focus on an element. Here is an example:

  <input type="text" style="outline: none;">

In the example above, we have used the outline property to remove the outline from an input field. When the user clicks on the input field, the outline will appear to indicate focus on the field.

Overall, the outline property is a useful tool for adding visual effects to HTML elements. It can be used to highlight elements, indicate focus, and create 3D effects. By using different styles and colors, you can create a variety of effects that will enhance the appearance of your web pages.

References

Activity