Hiding DOM Elements with Ease

<p hidden>I’m invisible!</p> No need to rely solely on JavaScript to hide elements. Utilize the native HTML hidden attribute. This has a similar effect to display: none; in CSS, making the element disappear. article

Read More

Checking Network Speed

if (navigator.connection) { const downlink = navigator.connection.downlink; console.log(`Current download speed: ${downlink} Mbps`); } else { console.log(“Network Information API not supported”); } article

Read More

Preventing Text Pasting

<input type=”text”></input> <script> const input = document.querySelector(‘input’); input.addEventListener(“paste”, function(e){ e.preventDefault() }) </script> article

Read More

Prevent text selection CSS

User-select property – prevent text selection To prevent text selection, you can add CSS: p { -webkit-user-select: none; /* Safari */ -ms-user-select: none; /* IE 10 and IE 11 */ user-select: none; /* Standard syntax */ } on specific class .prevent-select {-webkit-user-select: none; /* Safari */ -ms-user-select: none; /* IE 10 and IE 11 */ […]

Read More

CSS Comma-separated list

Comma-separated list Here’s a neat little trick that allows you to create a comma-separated list using just an HTML unordered list and a couple of lines of CSS. ul > li:not(:last-child):after { content: “, “; } In order for this to work you need to make sure to set the display property of the li tag to inline-block. <ul> <li>First […]

Read More

CSS External links

1. External links Styling external links can be done in several ways. One way to do this is by adding an extra class to all the external links. This is cumbersome and unnecessary since this can be done very easily by only using CSS. Let’s take a look at the following selector. a[href*=”//”]:not([href*=”yourwebsite.com”]) { /* […]

Read More

add external link icon before link

a[href*=”//”]:not([href*=”yourwebsite.com”]) { /* Apply style here */ } This CSS selector takes all a tags which href attribute contains two forward slashes (to filter out relative URLs) and which doesn’t contain the URL of your website. article

Read More