Jeremy Keith recently published Declarative designhttps://adactio.com/journal/18982 on his blog. The premise of the post is that there are two divergent ways to think about web design and building web content, encapsulated by these two opposed statements: CSS is broken and I want my tools to work around the way CSS has been designed. and CSS is awesome and I want my tools to amplify the way that CSS has been designed. Which of these statements resonates with you will influence the tools that you choose and the comfort you feel when you use tools that don't fit your paradigm. This...
Among the large number of new features in ES6/ES2015 are Template Literals/Stringshttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Templateliterals. These are backtick "\" enclosed expressions that allow for multiline expressions and string interpolations using placeholders ${varName}. js let name = "William" let carMake = "Ferrari" let myTemplateString = My name is ${name} and I own a ${carMake} // -> My name is William and I own a Ferrari White space is significant. Inserting spaces or newline characters will change the resulting string. If we insert newline characters into myTemplateString will produce a different result that may not be what you're expecting. js let name = "William" let...
CSS has evolved significantly over the last few years. Some of these changes deal with a set of selectors known as the functional pseudo-classes. The :not pseudo-class has been around for a while at least since IE9, but when the other selectors we'll discuss on the post were introduced in the Selectors Level 4https://w3c.github.io/csswg-drafts/selectors/ specification, the :nothttps://drafts.csswg.org/selectors/negation pseudo-class was changed to accept a selector list to keep it in line with the other functional pseudo-classes. The :is Pseudo-class The Matches-Any Pseudo-class accepts a comma-separated list of selectors and matches any element that can be selected by one of the items...
I am not going to rehash the "people don't disable Javascript" debate. Most of the time Javascript is enabled and everything is good. However, having Javascript enabled doesn't mean that Javascript will always work, as outlined in Everyone has JavaScript, right?https://www.kryogenix.org/code/browser/everyonehasjs.html There are times when we want to test how your page would work if Javascript is disabled or not present. This is the scenario we'll discuss in this post. We will leverage browsers' devTools to disable Javascript for the current session so we can test whether Javascript is enabled or not. Chrome The Chrome team provides a full explanation...
Evergreen browsers are those that update themselves automatically, or very close to it, without user intervention. This is particularly useful when it comes to new features. We don't have to wait for users up upgrade their browsers, the browsers will update themselves, at least in theory. In “Evergreen” Does Not Mean Immediately Availablehttps://css-tricks.com/evergreen-does-not-mean-immediately-available/, the author explains how evergreen auto updates may not work how you expect and users of modern computers may choose not to shut down their browsers and, as a result, not trigger automatic browser updates unless the user clicks on the download button and then clicks the...
I know that it's unlikely people will disable Javascript on their browsers, but it is not impossible. We can notify the user of the lack of Javascript using the scripting media query. This example will tell users whether Javascript is enabled on their browser. It is made of two parts. The first part is the content that we want to display to the user. We'll hide it and reveal the appropriate value with CSS later. html You do not have scripting available. Your scripting is only enabled during the initial page load. Weird. You have scripting enabled! The CSS does...
I've written about web components a lot over the years but not recently. I think it's time to take a look at where we're at, and the newer technologies that have emerged under the web components umbrella. What are web components? Web Components is the umbrella term for a set of technologies custom elements, shadow DOM and HTML templates that make it easier to create custom elements for your pages and applications. A web component may look like this when used in a web document: html And they would behave the same way as built-in elements like video and audio....
There may be times when we may want to style elements that are not direct descendants of the elements that we want to style. In Select an Element Which Doesn't Descend From Another in CSShttps://chriskirknielsen.com/blog/select-an-element-which-doesnt-descend-from-another-in-css/ Chris Nielsen outlines a way to do this using articles and links as examples. This is a skeleton of the content. html ... Link If we want to select a a element that is not a direct descendant of an element with the class .archived, we might start with code like this: css :not.archived > a { background-color: hotpink; } But this will not work...
When writing CSS one of the most annoying and repeating tasks is having to customize the styles for the last element in a list or other repetitive components. I've lost track of how many times I've had to tweak code like the code shown below where we override the margin-block-end or margin-bottom property on the last child element to remove the padding or margin. css .child { margin-bottom: 2rem; border: 1px solid red; width: 50vw; padding-block: 1rem; padding-inline-start: 2rem; } .child:last-child { margin-block-end: 0; } It's tedious and, potentially, error-prone. I may forget to add it or the last-child element...
Measuring long tasks in our code js // Test for long tasks test'should capture long tasks on the page', async { page } => { // Function to capture long tasks async function captureLongTasksdurationThreshold { return page.evaluatethreshold => { return new Promiseresolve => { const longTasks = ; const observer = new PerformanceObserverlist => { for const entry of list.getEntries { if entry.duration > threshold { longTasks.pushentry; } } }; observer.observe{ entryTypes: 'longtask' }; // Assuming the long tasks will be captured within a certain time frame setTimeout => { observer.disconnect; resolvelongTasks; }, 5000; // Adjust the timeout as needed...