---
title: "Tommy Hodgins (@tomhodgins) | Hashnode"
description: "CSS & Element Queries. Read the latest articles by Tommy Hodgins on Hashnode."
url: "https://hashnode.com/@tomhodgins"
---

@tomhodgins

# Tommy Hodgins

@tomhodgins · Toronto · Joined September 2016

CSS & Element Queries

[Website](http://codepen.io/tomhodgins)

## Comments

[I do all of these, however I'll just point out that <template> isn't fully functional in IE11 and below, and even worse is template strings won't work at all. So if you need a cross-browser solution that works in older browsers, document.createElement() is your option. Also, just a tip for older browsers that don't have <template> - if you want to add a block of multiline HTML or something into the page for templating purposes, you can put whatever you otherwise would have put into <template> in a <script> tag with a custom type="" attribute on it, and then find and work with the content of that tag in JS later: <script type=text/html> <h1>Multiline</h1> <h2>HTML</h2> <h3>Content</h3> </script>](https://hashnode.com/forums/thread/whats-your-preferred-method-for-creating-dom-elements-in-vanilla-js/comment/5cf92ccede11412c47ff411f)

Comment · Thread · Jun 6, 2019 · [What's your preferred method for creating DOM elements in vanilla JS?](https://hashnode.com/forums/thread/whats-your-preferred-method-for-creating-dom-elements-in-vanilla-js)

[Wow that's great Nick, CSS can be a ton of fun! The Mozilla Developer Network includes a lot of reference articles about CSS properties, but they also contain some great how-to articles that explain concepts and things that are otherwise hard to google for. Learn CSS: https://developer.mozilla.org/en-US/docs/Learn/CSS Example of a useful article I link people to regularly, How the Stacking Context works: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS\_Positioning/Understanding\_z\_index/The\_stacking\_context There's also a new section on MDN called the CSS Layout Cookbook, which includes recipes for common layout tasks, and if there's more than one way to do it, it explains the tradeoffs so you understand what you're working with: https://developer.mozilla.org/en-US/docs/Web/CSS/Layout\_cookbook Another great resource for learning CSS and staying up to date with CSS is https://css-tricks.com/ but keep in mind that this is a blog-site site, not a wiki, so you can still read and find really old and outdated information on there - just be aware of the publishing date. The new content on this site is some of the best CSS content around. Lastly, one that has helped me a lot is CSS-Tricks sister site, Codepen. I found that I could get better at CSS by practicing things, but rather than trying to build a whole website, I could make a Codepen and experiment with 10 button styles, or a handful of text shadow styles, or just work on improving my understanding of one little skill in isolation at a time. There are already thousands of pens on there you can look at and learn from too, and it's a nice community: https://codepen.io/](https://hashnode.com/forums/thread/where-are-good-places-to-start-diving-into-css/comment/5cf910569ca927162cffc26c)

Comment · Thread · Jun 6, 2019 · [Where are good places to start diving into CSS?](https://hashnode.com/forums/thread/where-are-good-places-to-start-diving-into-css)

[The most common thing I use reduce() for is producing Strings as output, by looping over and processing a list of some kind of data. I might be doing something like: reducing an Array of data into a String of HTML source reducing a NodeList of elements (like what gets returned from document.querySelectorAll()) in a webpage into a String of CSS source reducing a CSSStyleSheet into a String of CSS source reducing an Array of data into other formats (CSV, MD, TXT, JSON, JS, etc) and sometimes also outtputting that as data URIs I think the only time I've used it on numbers has been as a demo summing an Array of numbers to show what it can do, not for anything I've actually needed yet :D](https://hashnode.com/posts/functional-javascript-how-to-use-array-reduce-for-more-than-just-numbers/5ce546b532b49d9b601220e7/comment/5ceaf78f8e78b4f14b372f09)

Comment · Article · May 26, 2019 · [Functional JavaScript: How to use array reduce for more than just numbers](https://hashnode.com/posts/functional-javascript-how-to-use-array-reduce-for-more-than-just-numbers/5ce546b532b49d9b601220e7)

[It can all depend on what your needs are and what you're trying to do. A lot of the time I look for something that doesn't exist so I don't really have the option - I get to be the person to make the module for the first time. I think a lot of time people think their only options with a library or module is to either use it not use it And they don't consider that they can read it and learn from it and even cherry-pick and use the parts of it in their own codebase that they want to. Libraries are things you can learn from, not just run. Now, on the flip side of that, having peeked at enough libraries and modules out there, just because something exists doesn't mean it was implemented well and is a high-quality package either. You have to inspect and be very careful about the code you pull into your codebase because even though you didn't write it originally, if you use, now you also have to maintain it, at least as far as you have used it in your project. If you pull in Library A and there's a critical bug that pops up one day, it's not Library A that has a problem, it's you that has a problem. And it's not Library A that needs to rush out an urgent fix, it's you who needs to come up with some kind of urgent workaround or fix for your codebase. However, if there's a high-quality module already available, like Chrome Puppeteer which automates a headless Chrome web browser…it doesn't make sense to implement your own version of that. It's there, it's great, it's high-quality, you can feel pretty confident using it that it will work for you. One other thing to keep in mind any time you rely on code, tools, platforms, or workflows you didn't write -> you need to have an exit strategy planned out in advance and to build with this in mind. Suppose you use a certain booking plugin so website users can book a haircut…as you build that you need to keep in mind "if at a moment's notice we had to switch away from this booking plugin, what are other plugins we could replace it with, and how would we port our logic over?". Working like that can help you make smarter decisions about how you structure your codebase to abstract your own logic away from the plugins a little bit, making it less of a big deal if you have to totally replace a plugin later.](https://hashnode.com/forums/thread/modules-vs-self-written-logic/comment/5ceadafe95db08a629c9a259)

Comment · Thread · May 26, 2019 · [Modules vs Self-written logic](https://hashnode.com/forums/thread/modules-vs-self-written-logic)

[Before you think about selling code online, here's a couple questions to see if you're ready: How would you feel if you found people stealing/sharing/pirating your code for free? How would you feel if you found 5 people reselling your code as their own code, maybe even making more money than you? When was the last time you bought a font? When I was in college I interviewed a type designer and spoke to a few others and they were all the most bitter group of people you could imagine. They were sick and tired of people always stealing their stuff and felt entitled to money they never earned etc etc. I had been considering moving into that field but I didn't want to turn into a bitter old man. Later I've seen websites like Envato network where you can post code and people can buy it, and I'm sure they try their best to stop people reselling works they don't have a right to, but I'm sure it still happens, and you may never be able to track down who it is and get them to stop. If this would bother you, maybe selling such an easy-to-copy and hard-to-enforce thing isn't the right move. For me, the right move was to release all my code for free, open-source, and have people hire me to either write new code that doesn't exist yet, or to write the code that they need specifically. That way it doesn't really matter who has the code after it exists, or how many times it's copied, I get paid 1x to write it 1x and then it's out there.](https://hashnode.com/forums/thread/feedback-from-all-frontend-developers/comment/5ceab868879ee5615b13120e)

Comment · Thread · May 26, 2019 · [Feedback from all frontend developers](https://hashnode.com/forums/thread/feedback-from-all-frontend-developers)

[Is it okay for people who have studied these tools deeply, then chosen not to use the more poorly designed tools of the bunch in production to answer this question? It doesn't look like there are many answers…](https://hashnode.com/forums/thread/css-in-js-pros-and-cons/comment/5ceab653687e6cb95e2db51c)

Comment · Thread · May 26, 2019 · [CSS-in-JS: Pros and Cons](https://hashnode.com/forums/thread/css-in-js-pros-and-cons)

[In the past I used to think about CSS stylesheets as stylesheets that might contain the styles for an entire website, including every layout, every 'component', and all of the base styles like what color a link is or the font used for the text. In the present For the past ~10 years, responsive web design has become important and the nature of what gets put inside a CSS stylesheet has changed. I think it makes a lot of sense to split apart the structural page layout styles from the styles for the individual components that go into them - especially if the components use element queries for their breakpoints. By having all of one component's styles (including responsive breakpoints) grouped together in a way that can be copy/paste into other websites we can make the parts and pieces of our layout very modular and portable, while keeping our layouts simple to work with as well. In the future As websites get larger and more dynamic, the CSS stylesheets you have will get less and less important, and being able to generate the CSS you need to style the elements you have at any given moment will become more important. In the future we may only need 1 CSS stylesheet containing just enough styles to get you to "first paint" and displaying the website, and from there JavaScript may be used to template and generate the CSS you need. This also reduces the total overall CSS that has to be parsed and exist in CSSOM at any given time as well. In this situation, though we're still outputting CSS to actually get the styles onto the elements, because we're using JavaScript to help us that means how and where we express those styles doesn't necessarily need to look like a CSS stylesheet, it can be any way we chose to express those design intentions and styling.](https://hashnode.com/forums/thread/global-stylesheet-vs-component-level-stylesheets-which-one-do-you-currently-use-and-why/comment/5cab4e57cfef05b83da0618e)

Comment · Thread · Apr 8, 2019 · [Global stylesheet vs component level stylesheets? Which one do you currently use and why?](https://hashnode.com/forums/thread/global-stylesheet-vs-component-level-stylesheets-which-one-do-you-currently-use-and-why)

[I work for a few reasons: web design is the forefront of design as it evolves, if you have an interest in design it makes sense to want to be involved at least to know where it is, if not to help shape trendy web development is the scene of a lot of innovation when it comes to tools for software development (both for web and beyond) so if you have any interest in software development on any platform, learning about web tech right now is pretty hot I also enjoy helping people. If I can take something I know, or a skill I have and use it to help 1 person communicate to many people, it multiplies the amount of good I can do. Rather than just helping one person at a time, I can be helping dozens, or hundreds, or thousands - what could be more exciting and fulfilling than that? to push my own skills and personal development along. I come from a design background with training, but nobody ever taught me how to program, or about computer science. By continuing to work and learn and tackle new problems I can expand myself and become more than I was before.](https://hashnode.com/forums/thread/why-should-we-work/comment/5c5c4c005ec3c1fe669651d5)

Comment · Thread · Feb 7, 2019 · [Why should we work?](https://hashnode.com/forums/thread/why-should-we-work)

[If I have a plane ride I almost always end up bored with reading and watching, and end up coding, but being offline really forces you to poke around in your tools and do as much introspection inside your language as you can, since there's no way to look up any reference or documentation while offline. I regularly go to cafés here in town for an hour or two and sometimes I either choose not to connect, or just never get around to it because I'm too busy working and without the connection I forget I'm not connected unless I need to check something, and I don't get the interruptions of notifications either.](https://hashnode.com/forums/thread/how-is-your-internet-dependency/comment/5c5495e2eaea85531fd6b95a)

Comment · Thread · Feb 1, 2019 · [How is your internet dependency?](https://hashnode.com/forums/thread/how-is-your-internet-dependency)

[I have a couple of job interviews (today and Tuesday) and will be attending a hiring related meetup later this week :D As always I'm sure I'll be doing some fun CSS experiments too! So far this week I've come up with: live-updating character count with CSS variables: https://codepen.io/tomhodgins/pen/GzZYBR live-updating word count with CSS variables: https://codepen.io/tomhodgins/pen/VgaEOo invented a pseudo-class for when you've typed more characters of text than a set limit on an element: https://codepen.io/tomhodgins/pen/omxJoe](https://hashnode.com/forums/thread/hey-its-monday-what-are-you-working-on-and-whats-your-goal-for-this-week/comment/5c4f29e502aa50f4423295d8)

Comment · Thread · Jan 28, 2019 · [Hey it's Monday! What are you working on and what's your goal for this week?](https://hashnode.com/forums/thread/hey-its-monday-what-are-you-working-on-and-whats-your-goal-for-this-week)
