# element

Published articles for element.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## CSS fix to prevent orphan icons dropping to a new line

DevFeed: [CSS fix to prevent orphan icons dropping to a new line](<https://devfeed.tech/articles/css-fix-to-prevent-orphan-icons-dropping-to-a-new-line-37254.md>)

Original publisher: [Read original article](<https://muffinman.io/blog/css-fix-to-prevent-orphan-icons/>)

Author: Stanko

Published: 2024-11-12T00:00:00Z

Content type: tutorial

Language: en

Sources: [Stanko Tadić](<https://devfeed.tech/sources/stanko-tadic.md>)

Topics: [CSS](<https://devfeed.tech/topics/css.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>), [HTML](<https://devfeed.tech/topics/html.md>), [browser](<https://devfeed.tech/topics/browser.md>)

Tags: [browser](<https://devfeed.tech/tags/browser.md>), [css](<https://devfeed.tech/tags/css.md>), [element](<https://devfeed.tech/tags/element.md>), [legibility](<https://devfeed.tech/tags/legibility.md>), [property](<https://devfeed.tech/tags/property.md>)

### AI overview

This tutorial explains how CSS text wrapping can prevent short text or icons from becoming orphaned on a separate line. It presents text-wrap: balance and text-wrap: pretty, noting that pretty uses a slower layout algorithm and is not supported in Firefox or Safari at the time of writing.

### Source excerpt

When an HTML element becomes too narrow, its content starts to wrap into multiple lines. This is intended behavior and works well in many cases. However, for short text, it doesn't look great when the last word or icon drops to the next line, becoming an orphan. For example, you might see something like this: Click here for more info It doesn't look great when the icon is left alone on its own row. Luckily, there's a simple CSS solution. Solution # Only thing we need to add is a single line of CSS: text-wrap: balance; This property tells the browser to wrap the text in a way that best balances the number of characters on each line, enhancing layout quality and legibility. The browser will calculate this for us, preventing orphaned icons or words. text-wrap: pretty # There is also the pretty value for text-wrap, which is even better. It works in a similar way, but the browser will use a slower algorithm that prioritizes better layout over speed. Unfortunately, at the time of writing, pretty is not supported in Firefox nor Safari. However, you can define both values, and browsers that don't support pretty will fall back to balance. text-wrap: balance; text-wrap: pretty; /* This will be ignored by browsers that don't support it. */ Demo # Here's a simple demo. Use the handle on the right to resize the element and see how text breaks with and without the balance property applied. Defaulttext-wrap: balancetext-wrap: pretty Unfortunately your browser doesn't support text-wrap: pretty. Click here for more info A somewhat longer text that will break into multiple lines

## My Advice to a Developer New to Accessibility

DevFeed: [My Advice to a Developer New to Accessibility](<https://devfeed.tech/articles/my-advice-to-a-developer-new-to-accessibility-38446.md>)

Original publisher: [Read original article](<https://eevis.codes/blog/2022-07-22/my-advice-to-a-developer-new-to-accessibility/>)

Author: Eevis Panula

Published: 2023-01-03T08:57:33.125000Z

Content type: tutorial

Language: en

Sources: [Eevis Blog](<https://devfeed.tech/sources/eevis-blog.md>)

Topics: [Accessibility](<https://devfeed.tech/topics/accessibility.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>), [HTML](<https://devfeed.tech/topics/html.md>), [keyboard](<https://devfeed.tech/topics/keyboard.md>), [markup](<https://devfeed.tech/topics/markup.md>)

Tags: [accessibility](<https://devfeed.tech/tags/accessibility.md>), [accessible](<https://devfeed.tech/tags/accessible.md>), [advice](<https://devfeed.tech/tags/advice.md>), [developer](<https://devfeed.tech/tags/developer.md>), [development](<https://devfeed.tech/tags/development.md>), [element](<https://devfeed.tech/tags/element.md>), [elements](<https://devfeed.tech/tags/elements.md>), [focus](<https://devfeed.tech/tags/focus.md>), [html](<https://devfeed.tech/tags/html.md>), [html-elements](<https://devfeed.tech/tags/html-elements.md>), [input](<https://devfeed.tech/tags/input.md>), [interaction](<https://devfeed.tech/tags/interaction.md>), [interactive](<https://devfeed.tech/tags/interactive.md>), [keyboard](<https://devfeed.tech/tags/keyboard.md>), [learning](<https://devfeed.tech/tags/learning.md>), [markup](<https://devfeed.tech/tags/markup.md>)

### AI overview

This beginner-oriented accessibility article recommends focusing on progress rather than perfection and introduces semantic HTML, keyboard navigation, and listening to people with disabilities. It explains that semantic elements communicate meaning to browsers and developers and support appropriate interaction, while a div styled as a button may work only for mouse users and may not be focusable or keyboard-accessible.

### Source excerpt

Learning about accessibility for the first time can feel overwhelming. You start reading, and at some point, it hits you: There is so much to learn! And if you're like me and feel that it's your responsibility to make the things you create accessible, that might even make you feel anxious. And yes, there is a lot to learn regarding accessibility. But you don't need to know everything at once. As Meryl Evans reminds us in her tweet (and a blog post the tweet links to), it's about progress over perfection: https://twitter.com/merylkevans/status/1547635550466674692 So, here are some things I wish I had known when I first started learning accessibility. Heck, I wish I had known these things when I started learning web development! I'll share semantic HTML, keyboard navigation, and listening to people with disabilities. Learn Semantic HTML and Use It So, first thing: Learn semantic HTML. But what does it mean? Semantic HTML, or semantic markup, describes its meaning to the browser and developer in a human- and machine-readable way. So, with semantic elements, a human will know what the HTML element is about, and the browser knows what it should render and how it should behave when a user interacts with it. Here's an example: <button onClick={...}>I'm an honest button</button> That button uses a semantic button-element. When it does so, the browser knows what it should do when the user either clicks or activates it with a keyboard or other input device. Here's an example of a non-semantic "button": <div className="button" onClick={...}> I look like a button </div> So, this "button" made out of div looks like a button and even has the onClick-handler. So, wouldn't a human recognize it as a button? Well, yes and no. It depends on the human. You see, this "button" works only for mouse users. As div is not an interactive element by nature, it doesn't handle interaction the same way as, for example, a button-element. When using a semantic button-element, that onClick-event pro

## CSS blocky people making waves

DevFeed: [CSS blocky people making waves](<https://devfeed.tech/articles/css-blocky-people-making-waves-37253.md>)

Original publisher: [Read original article](<https://muffinman.io/blog/css-blocky-people-making-waves/>)

Author: Stanko

Published: 2022-11-10T00:00:00Z

Content type: tutorial

Language: en

Sources: [Stanko Tadić](<https://devfeed.tech/sources/stanko-tadic.md>)

Topics: [CSS](<https://devfeed.tech/topics/css.md>), [Web Components](<https://devfeed.tech/topics/web-components.md>), [HTML](<https://devfeed.tech/topics/html.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>)

Tags: [animate](<https://devfeed.tech/tags/animate.md>), [code](<https://devfeed.tech/tags/code.md>), [components](<https://devfeed.tech/tags/components.md>), [css](<https://devfeed.tech/tags/css.md>), [element](<https://devfeed.tech/tags/element.md>), [html](<https://devfeed.tech/tags/html.md>)

### AI overview

A tutorial on creating blocky people performing a stadium wave using only CSS. It explains how to build 3D boxes from HTML elements and CSS, then use Web Components templates to reduce the repeated HTML needed for each person.

### Source excerpt

It all started with the code challenge in our office. The weekly theme was waves, and I tried to think outside of the box. After dropping a few ideas, I remembered the waves people do on stadiumsAccording to Wikipedia these are known as Mexican or stadium waves. So I made waves using CSS only (code is available on CodePen): I started without a real idea on how to do it. Obviously, I needed to create some people and animate them. 3D people would be nice, but as this was a weekly code challenge, I had to keep it simple. Blocky people, similar to characters in Minecraft, seemed like a good idea. Making them using Three.js felt too obvious, as I wanted something a little bit more unconventional and fun. CSS was definitely not made for something like this, which is why I wanted to try it out. Box # Blocky people are obviously made of blocks, so I needed to build some 3D boxes in CSS. There are many tutorials on creating a 3D box in CSS, so I'll try to keep this short. We'll need six elements to use as sides of the box. Each side needs to be appropriately sized, rotated and translated into its place. <div class="box"> <div class="front"></div> <div class="back"></div> <div class="right"></div> <div class="left"></div> <div class="bottom"></div> <div class="top"></div> </div> Show HTMLHide HTML Here you can see the three steps in creating a CSS box: Size the sides appropriately Translate them into position Rotate them The box wrapper element is outlined in red and sides are outlined in blue. If you want to play with it, I created a standalone CodePen. As a bonus, here is a three-sided prism as well. WebComponents # Each box consists of seven HTML elements (a wrapper and six sides). And each person ended up being built from twelve boxes and some additional wrappers. That means that each person requires a lot of HTML to be written. To simplify things, we can use WebComponents. Web components are a pretty powerful tool, but in this case, we will only use their template capabi

## Eschewing Shadow DOM

DevFeed: [Eschewing Shadow DOM](<https://devfeed.tech/articles/eschewing-shadow-dom-31224.md>)

Original publisher: [Read original article](<https://every-layout.dev/blog/eschewing-shadow-dom/>)

Author: Heydon Pickering

Published: 2019-06-14T00:00:00Z

Content type: article

Language: en

Sources: [The Every Layout Blog](<https://devfeed.tech/sources/the-every-layout-blog.md>)

Topics: [Web Components](<https://devfeed.tech/topics/web-components.md>), [CSS](<https://devfeed.tech/topics/css.md>), [modern web development](<https://devfeed.tech/topics/modern-web-development.md>), [React](<https://devfeed.tech/topics/react.md>), [styled-components](<https://devfeed.tech/topics/styled-components.md>)

Tags: [css](<https://devfeed.tech/tags/css.md>), [custom](<https://devfeed.tech/tags/custom.md>), [element](<https://devfeed.tech/tags/element.md>), [react](<https://devfeed.tech/tags/react.md>), [styled-components](<https://devfeed.tech/tags/styled-components.md>)

### AI overview

An examination of styling problems encountered with Shadow DOM, including inconsistent universal styles, limited inheritance, slot restrictions, and specificity issues. The author proposes an experimental alternative for web components that namespaces and embeds prop-derived instance styles in the document head.

### Source excerpt

Regarding styling, Shadow DOM is really good at one thing: preventing per-component styles from leaking out and affecting other parts of the document. Unfortunately, Shadow DOM also has a very opinionated way of preventing styles being applied from the parent document. Here is a roundup of the quirks and associated issues I've encountered: Shadow DOM styling issues Universal styles Some universal styles (using the * selector) are applied, and others are not. The color property appears to pierce shadow boundaries, but I've had no luck with box-sizing. Having to set box-sizing: border-box for each component is redundant. Inheritance Document styles are inherited in Shadow DOM. But inheritance only gets you so far, especially since not all properties are inheritable by default anyway. I've tried hacking things together with the explicit inherit keyword, but that seems to have no effect. Using the following is no good, because it forces every node to inherit every property from the parent. If <my-component> had display: flex applied, every one of the component's descendants would adopt it. * { all: inherit; /* yikes */ } Slot restrictions For performance reasons, the ::slotted() selector, which allows you to style the Light DOM content of your component from within your Shadow DOM, only lets you affect child elements and not descendants at depth. This is a bit restrictive. Worse, you cannot seem to use sibling combinators like + or ~. None of the following works: ::slotted(*) + * /* Nope */ ::slotted(* + *) /* Nope */ ::slotted(*) + ::slotted(*) /* Nope */ Specificity In making layout components, I like to take a progressive approach: style the component and its Light DOM nodes in my document stylesheet, then enhance with instance-specific styles via props (attributes) in Shadow DOM. For a component instance that looks like this... <my-component itemWidth="10rem"></my-component> ...I would apply the itemWidth value in the Shadow DOM using interpolation: ` <style> ::slot

## Autocomplete Search with the Element API & VueJS

DevFeed: [Autocomplete Search with the Element API & VueJS](<https://devfeed.tech/articles/autocomplete-search-with-the-element-api-vuejs-31245.md>)

Original publisher: [Read original article](<https://nystudio107.com/blog/autocomplete-search-with-the-element-api-vuejs>)

Author: andrew@nystudio107.com (Andrew Welch)

Published: 2017-02-22T06:19:00Z

Content type: tutorial

Language: en

Sources: [nystudio107 | Articles on modern web development.](<https://devfeed.tech/sources/nystudio107-articles-on-modern-web-development.md>)

Topics: [Vue.js](<https://devfeed.tech/topics/vue.md>), [Content Management System](<https://devfeed.tech/topics/cms.md>), [API](<https://devfeed.tech/topics/api.md>), [Ajax](<https://devfeed.tech/topics/ajax.md>), [JSON](<https://devfeed.tech/topics/json.md>), [npm](<https://devfeed.tech/topics/npm.md>), [Front end](<https://devfeed.tech/topics/frontend.md>), [GitHub](<https://devfeed.tech/topics/github.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [autocomplete](<https://devfeed.tech/tags/autocomplete.md>), [cms](<https://devfeed.tech/tags/cms.md>), [cmss](<https://devfeed.tech/tags/cmss.md>), [craft](<https://devfeed.tech/tags/craft.md>), [create](<https://devfeed.tech/tags/create.md>), [element](<https://devfeed.tech/tags/element.md>), [fast](<https://devfeed.tech/tags/fast.md>), [feature](<https://devfeed.tech/tags/feature.md>), [functional](<https://devfeed.tech/tags/functional.md>), [github](<https://devfeed.tech/tags/github.md>), [heres](<https://devfeed.tech/tags/heres.md>), [insights](<https://devfeed.tech/tags/insights.md>), [json](<https://devfeed.tech/tags/json.md>), [npm](<https://devfeed.tech/tags/npm.md>), [search](<https://devfeed.tech/tags/search.md>), [vuejs](<https://devfeed.tech/tags/vuejs.md>)

### AI overview

A tutorial on using Craft CMS's Element API and VueJS to build an autocomplete search feature for blog entries. The Vue component sends AJAX requests to the Element API, receives JSON results, and renders them in a navigable dropdown.

### Source excerpt

Here's how to use Craft CMS's Element API and VueJS to create a fast, functional autocomplete search feature

## Lazy Loading with the Element API & VueJS

DevFeed: [Lazy Loading with the Element API & VueJS](<https://devfeed.tech/articles/lazy-loading-with-the-element-api-vuejs-31276.md>)

Original publisher: [Read original article](<https://nystudio107.com/blog/lazy-loading-with-the-element-api-vuejs>)

Author: andrew@nystudio107.com (Andrew Welch)

Published: 2016-12-17T17:45:00Z

Content type: tutorial

Language: en

Sources: [nystudio107 | Articles on modern web development.](<https://devfeed.tech/sources/nystudio107-articles-on-modern-web-development.md>)

Topics: [lazy loading](<https://devfeed.tech/topics/lazy-loading.md>), [Content Management System](<https://devfeed.tech/topics/cms.md>), [vuejs](<https://devfeed.tech/topics/vuejs.md>), [API](<https://devfeed.tech/topics/api.md>), [Front end](<https://devfeed.tech/topics/frontend.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [cms](<https://devfeed.tech/tags/cms.md>), [cms-s](<https://devfeed.tech/tags/cms-s.md>), [content](<https://devfeed.tech/tags/content.md>), [craft](<https://devfeed.tech/tags/craft.md>), [display](<https://devfeed.tech/tags/display.md>), [element](<https://devfeed.tech/tags/element.md>), [frontend](<https://devfeed.tech/tags/frontend.md>), [here-s](<https://devfeed.tech/tags/here-s.md>), [insights](<https://devfeed.tech/tags/insights.md>), [lazy](<https://devfeed.tech/tags/lazy.md>), [lazy-loading](<https://devfeed.tech/tags/lazy-loading.md>), [load](<https://devfeed.tech/tags/load.md>), [vuejs](<https://devfeed.tech/tags/vuejs.md>)

### AI overview

A tutorial on using Craft CMS's Element API with VueJS to lazy-load additional blog entries and display them on a frontend. It explains how to create an API endpoint that returns paginated blog content, including titles, URLs, summaries, images, categories, and tags.

### Source excerpt

Here's how to use Craft CMS's Element API to lazy load content and display it via VueJS on the frontend

## Plain JavaScript animated window scroll function

DevFeed: [Plain JavaScript animated window scroll function](<https://devfeed.tech/articles/plain-javascript-animated-window-scroll-function-37237.md>)

Original publisher: [Read original article](<https://muffinman.io/blog/animate-window-scroll-to/>)

Author: Stanko

Published: 2016-09-28T00:00:00Z

Content type: tutorial

Language: en

Sources: [Stanko Tadić](<https://devfeed.tech/sources/stanko-tadic.md>)

Topics: [JavaScript](<https://devfeed.tech/topics/javascript.md>), [Vanilla JavaScript](<https://devfeed.tech/topics/vanilla-js.md>), [npm](<https://devfeed.tech/topics/npm.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>)

Tags: [element](<https://devfeed.tech/tags/element.md>), [import](<https://devfeed.tech/tags/import.md>), [input](<https://devfeed.tech/tags/input.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [npm](<https://devfeed.tech/tags/npm.md>), [object](<https://devfeed.tech/tags/object.md>)

### AI overview

A tutorial presenting a plain JavaScript function for smoothly animating window scrolling without requiring jQuery. It documents the animated-scroll-to npm package, including installation, usage, duration settings, the scroll element, and cancellation on user input.

### Source excerpt

Before modern frameworks, I always used jQuery's scrollTo method. At some point, not every project included jQuery, so I wrote simple function to animate window scroll. I have kept copying that function from project to project. Finally I took some time, cleaned it up and published it on the npm (this is the first npm package I published). Check the demo and read documentation of Github. Find it on Github and npm Installation # npm install animated-scroll-to Usage # import animateScrollTo from 'animated-scroll-to'; // desiredOffset - page offset to scroll // options - object with options // default options const options = { // duration of the scroll per 1000px, default 500 speed: 500, // minimum duration of the scroll minDuration: 250, // maximum duration of the scroll maxDuration: 1500, // DOM element to scroll, default window // Pass a reference to a DOM object // Example: document.querySelector('#element-to-scroll'), element: window, // should animated scroll be canceled on user scroll/keypress // if set to "false" user input will be disabled until animated scroll is complete cancelOnUserAction: true }; const desiredOffset = 1000; animateScrollTo(desiredOffset, options);

## Streaming Median

DevFeed: [Streaming Median](<https://devfeed.tech/articles/streaming-median-40277.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2012/06/14/streaming-median/>)

Published: 2012-06-14T22:03:55Z

Content type: tutorial

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [Streaming](<https://devfeed.tech/topics/streaming.md>), [Python](<https://devfeed.tech/topics/python.md>), [Algorithms](<https://devfeed.tech/topics/algorithms.md>), [generators](<https://devfeed.tech/topics/generators.md>), [iteration](<https://devfeed.tech/topics/iteration.md>), [Programming](<https://devfeed.tech/topics/programming.md>)

Tags: [algorithm](<https://devfeed.tech/tags/algorithm.md>), [approximation](<https://devfeed.tech/tags/approximation.md>), [big-data](<https://devfeed.tech/tags/big-data.md>), [data-analysis](<https://devfeed.tech/tags/data-analysis.md>), [element](<https://devfeed.tech/tags/element.md>), [generators](<https://devfeed.tech/tags/generators.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [infinite](<https://devfeed.tech/tags/infinite.md>), [input](<https://devfeed.tech/tags/input.md>), [iteration](<https://devfeed.tech/tags/iteration.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [median](<https://devfeed.tech/tags/median.md>), [programming](<https://devfeed.tech/tags/programming.md>), [python](<https://devfeed.tech/tags/python.md>), [sequence](<https://devfeed.tech/tags/sequence.md>), [streaming](<https://devfeed.tech/tags/streaming.md>), [streaming-data](<https://devfeed.tech/tags/streaming-data.md>), [yield](<https://devfeed.tech/tags/yield.md>)

### AI overview

This tutorial presents a Python generator that approximates the median of a potentially infinite integer sequence using constant space. The algorithm adjusts its current estimate by one for each input value that is above or below the estimate, and the article discusses how changing stream distributions affect the result.

### Source excerpt

Problem: Compute a reasonable approximation to a "streaming median" of a potentially infinite sequence of integers. Solution: (in Python) def streamingMedian(seq): seq = iter(seq) m = 0 for nextElt in seq: if m > nextElt: m -= 1 elif m < nextElt: m += 1 yield m Discussion: Before we discuss the details of the Python implementation above, we should note a few things. First, because the input sequence is potentially infinite, we can't store any amount of information that is increasing in the length of the sequence.