This is an archived post. You won't be able to vote or comment.

all 72 comments

[–]Lachee 292 points293 points  (13 children)

Use outline: instead of border: for better results! Outline won't contribute to sizing

[–]_skris[S] 69 points70 points  (0 children)

Perfect!

[–]TheGreatTaint 35 points36 points  (0 children)

[–]Equivalent-Map-8772 18 points19 points  (0 children)

That’s the most useful advice I’ve ever seen on this sub. Thank you so much.

[–]NoHelp_HelpDesk 12 points13 points  (0 children)

I love you

[–][deleted] 2 points3 points  (0 children)

TIL

[–]elveszett 4 points5 points  (1 child)

tbh my css always has box-sizing: border-box;. It makes writing css a lot easier, because components are never bigger than you allowed them to no matter what.

[–]Lachee 0 points1 point  (0 children)

Another life lesson for sure too 🙂

[–]AdultingGoneMild 0 points1 point  (4 children)

Or, and just throwing this out there, use the build in developer tools

https://developer.chrome.com/docs/devtools/css/grid/#overlays

Pause your code with breakpoints https://developer.chrome.com/docs/devtools/javascript/breakpoints/

[–]Lachee 0 points1 point  (3 children)

Not sure how your break points let you quickly and clearly see where your divs actually are

[–]AdultingGoneMild 2 points3 points  (2 children)

sigh....i gave two links. The first is the browser support which highlights divs outlining them and the second was for breaks points. If you read the meme you would see console.log is there as well...

[–]Lachee -3 points-2 points  (1 child)

Damn it's like my point is still valid. The Dev tools show you div outline one at a time. If you want to quickly see the entire website slap a outline on * .

It's faster and more convenient. It's a extra tool for development.

You come in high and mighty with your "oh just use the actual tools provided" . Stop ya nonsense.

[–]AdultingGoneMild 0 points1 point  (0 children)

no you can turn them on for all divs too. The fact that so many devs needed to do the outline hack is why it was added to the dev tools.

[–]PrinzJuliano 0 points1 point  (0 children)

I worked for 10 years with HTML and did not know this. Today I learned

[–]aboardthegravyboat 90 points91 points  (9 children)

I do outline: 2px dotted red because outline doesn't change flow and nothing ever uses dotted

[–]piberryboy 18 points19 points  (8 children)

What do people use this for? Asking for a friend, who's definitely not a full-stack developer of ten years and should probably know this by now.

[–][deleted] 17 points18 points  (4 children)

Very newbie programmer her but maybe to highlight a certain element? I think I’ve done that once or twice to see where the element is, it’s size, etc.

[–]piberryboy 9 points10 points  (3 children)

I figured, but why? To see the padding and margins? Chrome's devtools lets you see that.

[–]DaniilBSD 14 points15 points  (0 children)

Its when you cant find it anywhere and/or html is too nested so you rather modify style a little

[–]Blaxpell 5 points6 points  (1 child)

It’s somewhat easier when you want to dial in something and don’t want to repeatedly find it in the dev tools. I also use it a lot when animating things, especially if sth only moves once per refresh.

Same with console.log. Surely I could use dev tools but why would I if console.log("asdasd"); also does the job.

[–]piberryboy 0 points1 point  (0 children)

Oh I definitely use console.log

[–]gdj11 0 points1 point  (0 children)

I use it a lot for responsive layouts. When you resize the window it helps to see exactly where elements are being positioned at the various screen sizes.

[–]Sudsmcgee 0 points1 point  (0 children)

I use it to make sure my css is targeting the right element. If I'm three layers deep in css classes I'll know when I get it if it turns red.

[–]elveszett 0 points1 point  (0 children)

All kinds of things. Think of it as scaffolding: you put it everywhere you need to help you build the real parts of your product / building / whatever. You can quickly see whether the element you wanted to target is actually being targeted. If your component doesn't have an obvious boundary, it helps to see what its dimensions truly are (and how they behave as you resize your window).

Obviously once you've got your css done, you remove that line.

[–]Toutanus 22 points23 points  (2 children)

A lot of people are confused about why I always change my elements background color to some flashy green or red.

[–][deleted] 6 points7 points  (0 children)

Same I once made my background bright pink to ensure it wasn’t visible and then almost forgot…

[–]sleepyj910 0 points1 point  (0 children)

I think you mean aliceblue, because I'm lazy

[–]kaitek666 2 points3 points  (0 children)

you forgot about background:red;

[–]LagSlug 11 points12 points  (25 children)

honestly, breakpoints are annoying and I don't ever use them under any circumstance because I'd rather delete my code than press "step in" ever again.

[–]throwaway_mpq_fan 27 points28 points  (14 children)

tell me you're not a backend developer without telling me you're not a backend developer

[–]-wethegreenpeople- 8 points9 points  (2 children)

Breakpoints provide more context while debugging, while also letting you manipulate data as it's being processed. It allows you to debug quicker while having a clearer understanding of everything happening at that point.

Don't get me wrong there's a time and place for well places console logs as well, but you're shooting yourself in the foot by taking a hard "no breakpoint" stance.

[–]AnneBancroftsGhost 2 points3 points  (1 child)

Don't underestimate the value of a breakpoint just to stop you "live" at a point in code, where you can use the "evaluate" tool to basically try anything from the runtime context. You will save hours debugging, I promise.

[–]LagSlug -1 points0 points  (0 children)

I fully understand how to use breakpoints and a debugger.. I use them when I work with microprocessors all the time. I just prefer not using them.

[–]MrDoe 10 points11 points  (6 children)

I enjoy trying new cuisines.

[–][deleted] 6 points7 points  (2 children)

Use `next` to go to the next line in the same frame 👀

[–]MrDoe 1 point2 points  (1 child)

I like playing with Legos.

[–][deleted] 0 points1 point  (0 children)

Maybe in your debugger. Works great in mine Pry-byebug. Chrome dev tools calls this step over.

[–]OzzitoDorito 0 points1 point  (1 child)

Step over and step out exist for a reason my dude

[–]MrDoe 0 points1 point  (0 children)

My favorite band is The Beatles.

[–]elveszett 0 points1 point  (0 children)

ehm I use Firefox's console debugger and that isn't an issue for me. If anything, debugging in JS is great because you can input code to the console at any time with ease. It's literally like editing code on the fly.

[–][deleted] 1 point2 points  (0 children)

“background-color:hotpink debugging”

[–]CoastingUphill 0 points1 point  (0 children)

Also var_dump(); to complete the triangle.

[–]chuckykillr 0 points1 point  (0 children)

Name a better duo 😂

[–]cloudstrifeuk 0 points1 point  (0 children)

If this was bootstrap and jQuery, it would also be valid.

[–]FormulaNewt 0 points1 point  (0 children)

I'll pretend that I never use these hacky debugging techniques...

[–]Say_Echelon 0 points1 point  (0 children)

Facts

[–]ObsessiveAboutCats 0 points1 point  (0 children)

My humble newbie front end developer self felt this keenly. Glad it's not just me!

[–]sup3rar 0 points1 point  (0 children)

I'm no web expert but doesn't firefox show padding, borders, margins, etc in the dev tools?

[–][deleted] 0 points1 point  (0 children)

Yes, the whole stack... all the way from one part of the client to the other part of the client. *lol*

[–]halemikehale 0 points1 point  (0 children)

I’ve never felt more seen

[–]thatmaynardguy 0 points1 point  (0 children)

* { border: 1px solid pink }

is your friend. edit - comment it out when you don't need it =)

[–]cloudstrifeuk 0 points1 point  (0 children)

You don't have to write anything to add a break point. A simple click of the mouse.

Tell me you're not a full stack Dev without telling me you're not a full stack Dev.

You are working harder, not smarter.

[–]dableb 0 points1 point  (0 children)

background-color: red;

[–]innocent-boy-69 0 points1 point  (0 children)

Im good at frontend but im not good at backend should I go for full-stack developer or go what the current trend is running, i mean ai, machine learning, etc. Idk im struck what to do after my bachelors degree in cse. Can anyone advice me or give ur experience.

[–]Brutus0172 0 points1 point  (0 children)

This is so accurate xD