CSS Tricks & Tips – Use Outline instead of Border to see elements

Video guide to using Outline in CSS

Here is a quick css trick for helping to see where your elements are placed in a website.

Outline does not affect dimensions like Border. It’s a handy way of showing where your elements are.

Use outline instead of border to place lines around your elements. Outline does not take up space or effect pixel layouts because it does not effect the dimensions of an element where as using border does.

html {
  box-sizing: border-box;
  outline: black solid 2px;
}
*, *:before, *:after {
  box-sizing: inherit;
  outline: inherit;
}

Use this with box-sizing: border-box; to make sizing and placing elements a bit easier!

I’ve linked a w3 schools page if you want more info and this tip was given to me by a fellow streamer andee927, I’ve also linked his twitch channel if you want to check him out.
W3Schools Article: https://www.w3schools.com/css/css_outline.asp
Andee927 Twitch: https://www.twitch.tv/andee927

Feel free to comment any tips you guys like using. Hope that helps and hope you guys are staying safe and sane out there. I’ll catch you guys next time!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s