A Better Google Analytics Alternative

Fullres

Our recent migration to GA4 left a lot to be desired and led us to explore for better google analytics alternatives. We tried just about everything out there, including Plausible, Fathom, and several others, all with their own pros and cons. The biggest hurdles were: limited features and higher costs.

That’s why we were so excited when we stumbled across Fullres recently. Not only do they have the best pricing around but they’re bundling multiple tools we use—ad revenue, analytics, web vitals—all into a single platform. Usually, you have to subscribe to multiple services and jump between browser tabs to see that amount of data together. Looking at their roadmap, there’s a lot more coming too.

Fullres also stood out with their quick 5-second installation setup. You get instant access to audience statistics in a GDPR-compliant manner and built-in Web Vitals data to continuously improve key metrics such as First Contentful Paint (FCP), Largest Contentful Paint (LCP), and other more.

For those who found the switch to GA4 challenging, Fullres is worth a try. It’s currently invite-only, so join the waitlist as soon as possible to get early access.

How to convert any website into fully editable Figma designs

We’ve all been there: Manually recreating website designs in Figma, desktops cluttered with screenshots for benchmarking, improving web copy without design context…

But what if there was a way to import a full webpage into Figma in just a few clicks? What if you could then edit the imported webpage; changing everything from text, to colors, to layout?

Look no further than html.to.design!

What is html.to.design?

html.to.design is a powerful Figma plugin that converts any website into fully editable Figma designs. Import full webpages into Figma to leverage an existing website and kickstart design work, saving you hours of time that would otherwise be spent manually recreating each element from scratch.

How does it work?

1. Once you have a website to import…

Copy-paste the URL of the webpage(s) you want to import. You can stick to just the landing page or import all pages in bulk for the full site.

2. Before clicking “Import”…

Select the viewport and theme you need. Desktop in light mode? Mobile in dark? Import the same webpage with different setting combinations for a full overview of the range of designs.

3. You now have your webpage in Figma!

But the magic doesn’t stop there. The webpage is fully editable, so you can change copy, colors, and move sections around. Plus, text and color styles are automatically grabbed and created as local styles in Figma, so you have them readily available for future designs.

4. If you need to import a private page…

Use the html.to.design browser extension! Log in to the webpage you need, then click on the html.to.design extension icon. It will immediately start downloading an .h2d file which you can drag-and-drop into the Figma plugin.

What can I use html.to.design for?

html.to.design can help by automating tasks that are manual and time-consuming for designers, developers, UX writers and anyone using Figma. Here are just a few use cases:

  • Redesign an old website and import all its elements as your base.
  • Experiment with different copy and see exactly how it’ll appear on the site.
  • Import missing design assets for ongoing projects.
  • Get inspired by other websites and create benchmarks without a single screen capture.
  • Check your website’s visual accessibility in Figma.

What are the benefits of html.to.design?

Save time

The number one benefit of using html.to.design as part of your design workflow is the amount of time it saves. Recreating a site or building design elements from scratch can take hours. html.to.design allows you to use any website as a base, importing everything as fully editable layers that you can turn into components, rearrange and redesign into something else. This means that you save time to focus on other important aspects of your design project, such as improving the user experience or perfecting the layout.

No design skills required

html.to.design is also great for anyone who is just starting out with Figma, or developers who need design assets from an existing site. The simplicity of the plugin means you don’t need to be an experienced product designer to use it. Anyone can import a webpage to use as a base, or even as an aid when learning how to use Figma.

Great for collaboration

html.to.design is also great for collaboration and brainstorming sessions. When working on a redesign project, for example, you and your team can use the plugin to import the website you’re working on, to then take advantage of Figma’s collaboration features. It’s much easier to work on the old website in an editable format, so your design team can change or move elements around and collaborate in real time.

Get design assets easily

Even if you don’t need the full website, html.to.design can still be helpful. The plugin also allows you to extract design assets from any website, such as images and fonts. html.to.design will even create local Figma styles for you, automatically! Instead of manually downloading each asset, you can easily extract them in just a few clicks, bringing all the design assets you need directly into Figma. This makes it easier for you to access them when working on future designs.

Ready to give it a try?

So, if you’re looking for a powerful tool to help streamline your design workflow, look no further than html.to.design. It’s already loved by over 360,000 people worldwide!

In just a few clicks you’ll have the fully editable Figma layers you need to redesign an old website or kickstart a new one. Try it out with 12 free imports per month, and see for yourself the difference it can make in your design workflow.

Implementing Adaptive Dark Mode Based on User’s OS Settings: A Step-by-Step Guide

More and more users prefer browsing websites in dark mode to reduce eye strain and save battery life. To provide the best user experience, it’s helpful to implement an automatic dark mode on your website that adjusts according to a user’s operating system settings. In this tutorial, we’ll walk you through the steps to achieve this.

Your Web Designer Toolbox
Unlimited Downloads: 500,000+ Web Templates, Icon Sets, Themes & Design Assets


 

1. Create a CSS file for dark mode

First, create a separate CSS file called “darkmode.css” that contains the styles for your website’s dark mode. This file should include the color palette, font styles, and other design elements that cater to dark mode. For example:

body {
  background-color: #121212;
  color: #ffffff;
}

h1, h2, h3, h4, h5, h6 {
  color: #f0f0f0;
}

a {
  color: #ffffff;
  text-decoration: underline;
}

2. Link the dark mode CSS file

In your website’s main HTML file, add the following link tag inside the head section to reference the dark mode CSS file:

<link id="darkmode-stylesheet" rel="stylesheet" href="darkmode.css" media="(prefers-color-scheme: dark)" />

The “media” attribute ensures that the dark mode CSS file will only be applied if the user’s operating system is set to dark mode.

3. Detect operating system’s color scheme

Now it’s time to detect the user’s operating system color scheme with JavaScript. Create a new JavaScript file called “darkmode.js” and add the following code:

function getSystemColorScheme() {
  return window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
}

This function checks if the user’s operating system is set to dark mode or light mode by evaluating the ‘prefers-color-scheme’ media query.

4. Save the user’s preference

To improve the user experience, we’ll save their preference in the browser’s local storage. Add the following code to the “darkmode.js” file:

function saveUserPreference(preference) {
  localStorage.setItem('color-scheme', preference);
}

function loadUserPreference() {
  return localStorage.getItem('color-scheme');
}

These two functions save and load the user’s color scheme preference, respectively.

5. Toggle dark mode

Create a function to toggle dark mode on and off by adding or removing the “dark” class from the HTML body element:

function toggleDarkMode(enableDarkMode) {
  if (enableDarkMode) {
    document.body.classList.add('dark');
  } else {
    document.body.classList.remove('dark');
  }
}

6. Initialize dark mode based on user preference or system settings

Now, add a function to initialize dark mode on page load. This function checks if the user has a saved preference in local storage; if not, it defaults to their operating system’s settings:

function initializeDarkMode() {
  const userPreference = loadUserPreference();

  if (userPreference) {
    toggleDarkMode(userPreference === 'dark');
  } else {
    const systemColorScheme = getSystemColorScheme();
    toggleDarkMode(systemColorScheme === 'dark');
  }
}

document.addEventListener('DOMContentLoaded', initializeDarkMode);

7. Allow users to toggle dark mode manually

As a fallback and also providing a better experience for your users, it is a good practice to give them the ability to switch between dark and light modes manually. To do this, add a button or a switch element in your website’s main HTML file:

<button id="toggle-darkmode">Toggle Dark Mode</button>

Next, add an event listener for this button in your “darkmode.js” file:

function handleDarkModeToggle() {
  const currentPreference = loadUserPreference() || getSystemColorScheme();
  const newPreference = currentPreference === 'dark' ? 'light' : 'dark';

  toggleDarkMode(newPreference === 'dark');
  saveUserPreference(newPreference);
}

document.getElementById('toggle-darkmode').addEventListener('click', handleDarkModeToggle);

This function toggles dark mode, saves the new preference in local storage, and updates the user interface.

8. Listen for operating system changes

To ensure that your website’s dark mode adapts to changes in the user’s operating system settings, add an event listener to the “darkmode.js” file that listens for changes to the ‘prefers-color-scheme’ media query:

function handleSystemColorSchemeChange(event) {
  if (!loadUserPreference()) {
    toggleDarkMode(event.matches);
  }
}

window.matchMedia('(prefers-color-scheme: dark)').addListener(handleSystemColorSchemeChange);

This function checks if the user has a saved preference in local storage. If not, it toggles dark mode based on the updated operating system settings.

9. Link the JavaScript file

Finally, include the “darkmode.js” file in your main HTML file by adding the following script tag inside the head section:

<script src="darkmode.js" defer></script>

The “defer” attribute ensures that the script is executed only after the HTML document has been fully parsed.

All done! Now you have everything you need to implement dark mode on your future projects!

The Importance of Color Contrast in Web Design

One of the most important aspects of web design is color contrast, which refers to the difference in brightness and/or color between two elements on a page. In this article, we’ll explore why color contrast is important for accessibility, and provide some code examples to help you improve the color contrast on your own website.

Your Designer Toolbox
Unlimited Downloads: 500,000+ Web Templates, Icon Sets, Themes & Design Assets


Why is color contrast important for accessibility?

Color contrast is important for accessibility because it allows users with visual impairments to easily distinguish between different elements on a page. For example, a user with color blindness may have difficulty differentiating between text and background colors that are too similar. Similarly, a user with low vision may struggle to read text that is too small or doesn’t have enough contrast with its background.

To ensure that your website is accessible to all users, it’s important to consider the contrast between all elements on your page, including text, graphics, and backgrounds. The Web Content Accessibility Guidelines (WCAG) provide specific guidelines for color contrast ratios that must be met in order to ensure accessibility for all users.

What are the WCAG color contrast guidelines?

The WCAG provides specific guidelines for color contrast ratios based on the size and weight of the text being displayed. The guidelines are divided into two levels: Level AA and Level AAA. Level AA is the minimum standard for web accessibility, while Level AAA provides a higher level of accessibility for users with more severe visual impairments.

For Level AA compliance, the WCAG requires a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text (18pt or 14pt bold). For Level AAA compliance, the contrast ratio must be at least 7:1 for normal text and 4.5:1 for large text.

To calculate the contrast ratio between two colors, you can use a tool such as the Contrast Checker from WebAIM. Simply enter the hex codes for your foreground and background colors, and the tool will calculate the contrast ratio for you.

Code examples for improving color contrast

Here are some code examples to help you improve the color contrast on your own website:

Increase text contrast

To increase the contrast between your text and background, you can adjust the color of your text or background. For example, if you have white text on a light gray background, you could darken the background or lighten the text to improve the contrast.

/* Before */
body {
  background-color: #f2f2f2;
}
h1 {
  color: #ffffff;
}

/* After */
body {
  background-color: #d6d6d6;
}
h1 {
  color: #ffffff;
}

Add text shadows

Another way to improve text contrast is to add a text shadow. This can help the text stand out from its background, especially if the background is a pattern or image that makes it difficult to read text.

/* Before */
h2 {
  color: #ffffff;
  background-image: url("background.jpg");
}

/* After */
h2 {
  color: #ffffff;
  text-shadow: 1px 1px #000000;
  background-image: url("background.jpg");
}

Use a color contrast checker

To ensure that your website meets the WCAG guidelines, you can use a color contrast checker. There are many free online tools available, such as the Contrast Checker from WebAIM or the Contrast Checker from Acart Communications.

/* Before */
body {
  background-color: #ffffff;
  color: #dddddd;
}

/* After */
body {
  background-color: #ffffff;
  color: #333333;
}

Avoid color combinations that are difficult to read

Certain color combinations can be difficult to read, especially for users with color vision deficiencies. For example, red and green are often difficult to distinguish for users with protanopia (a type of color blindness). To ensure that your website is accessible to all users, it’s important to avoid using color combinations that may be difficult to read.

/* Before */
a {
  color: #ff0000;
  background-color: #00ff00;
}

/* After */
a {
  color: #000000;
  background-color: #ffffff;
}

Provide alternative text for images

Images can also impact color contrast on a page. If an image contains text, it’s important to ensure that the text has enough contrast with its background. Additionally, if an image cannot be displayed for any reason, it’s important to provide alternative text that describes the image.

/* Before */
<img src="image.jpg">

/* After */
<img src="image.jpg" alt="A blue sky with white clouds">

Conclusion

Color contrast is an important aspect of web design that can have a significant impact on the accessibility of your website. By following the WCAG guidelines and implementing some of the code examples provided in this article, you can ensure that your website is accessible to all users, regardless of their visual abilities. Remember that accessibility is not only important for users with disabilities, but it also benefits all users, including those who may be using a mobile device or browsing in a noisy environment. By prioritizing accessibility in your web design, you can create a better experience for all users.

JavaScript Snippets For Better UX and UI

JavaScript can be used to significantly improve the user experience (UX) and user interface (UI) of your website. In this article, we will discuss some JavaScript snippets that you can use to boost the UX and UI of your website.

UNLIMITED DOWNLOADS: 500,000+ WordPress & Design Assets

Sign up for Envato Elements and get unlimited downloads starting at only $16.50 per month!

Smooth Scrolling

Smooth scrolling is a popular UX feature that makes scrolling through web pages smoother and more fluid. With this feature, instead of abruptly jumping to the next section of the page, the user will be smoothly transitioned to the next section.

To add smooth scrolling to your website, you can use the following JavaScript code:

$('a[href*="#"]').on('click', function(e) {
  e.preventDefault()

  $('html, body').animate(
    {
      scrollTop: $($(this).attr('href')).offset().top,
    },
    500,
    'linear'
  )
})

This code will create a smooth scrolling effect whenever the user clicks on a link that includes a # symbol in the href attribute. The code targets all such links and adds a click event listener to them. When the user clicks on a link, the code will prevent the default action of the link (i.e., navigating to a new page) and instead animate the page to scroll smoothly to the section of the page specified by the link’s href attribute.

Dropdown Menus

Dropdown menus are a common UI element that can help to organize content and improve the navigation of your website. With JavaScript, you can create dropdown menus that are easy to use and intuitive for your users.

To create a basic dropdown menu with JavaScript, you can use the following code:

var dropdown = document.querySelector('.dropdown')
var dropdownToggle = dropdown.querySelector('.dropdown-toggle')
var dropdownMenu = dropdown.querySelector('.dropdown-menu')

dropdownToggle.addEventListener('click', function() {
  if (dropdownMenu.classList.contains('show')) {
    dropdownMenu.classList.remove('show')
  } else {
    dropdownMenu.classList.add('show')
  }
})

This code will create a simple dropdown menu that can be toggled by clicking on a button with the class dropdown-toggle. When the button is clicked, the code will check if the dropdown menu has the class show. If it does, the code will remove the class, hiding the dropdown menu. If it doesn’t, the code will add the class, showing the dropdown menu.

Modal Windows

Modal windows are another popular UI element that can be used to display important information or to prompt the user for input. With JavaScript, you can create modal windows that are responsive, accessible, and easy to use.

To create a basic modal window with JavaScript, you can use the following code:

var modal = document.querySelector('.modal')
var modalToggle = document.querySelector('.modal-toggle')
var modalClose = modal.querySelector('.modal-close')

modalToggle.addEventListener('click', function() {
  modal.classList.add('show')
})

modalClose.addEventListener('click', function() {
  modal.classList.remove('show')
})

This code will create a modal window that can be toggled by clicking on a button with the class modal-toggle. When the button is clicked, the code will add the class show to the modal window, displaying it on the page. When the close button with the class modal-close is clicked, the code will remove the show class, hiding the modal window.

Sliders

Sliders are a popular UI element that can be used to display images or other types of content in a visually appealing and engaging way. With JavaScript, you can create sliders that are easy to use and customizable to fit your website’s design.

To create a basic slider with JavaScript, you can use the following code:

var slider = document.querySelector('.slider')
var slides = slider.querySelectorAll('.slide')
var prevButton = slider.querySelector('.prev')
var nextButton = slider.querySelector('.next')
var currentSlide = 0

function showSlide(n) {
  slides[currentSlide].classList.remove('active')
  slides[n].classList.add('active')
  currentSlide = n
}

prevButton.addEventListener('click', function() {
  var prevSlide = currentSlide - 1
  if (prevSlide &lt; 0) {
    prevSlide = slides.length - 1
  }
  showSlide(prevSlide)
})

nextButton.addEventListener('click', function() {
  var nextSlide = currentSlide + 1
  if (nextSlide &gt;= slides.length) {
    nextSlide = 0
  }
  showSlide(nextSlide)
})

This code will create a slider that can be navigated by clicking on buttons with the classes prev and next. The code uses the showSlide function to show the current slide and hide the previous slide whenever the slider is navigated.

Form Validation

Form validation is an essential UX feature that can help to prevent errors and improve the usability of your website’s forms. With JavaScript, you can create form validation that is responsive and user-friendly.

To create form validation with JavaScript, you can use the following code:

var form = document.querySelector('form')

form.addEventListener('submit', function(e) {
  e.preventDefault()
  var email = form.querySelector('[type="email"]').value
  var password = form.querySelector('[type="password"]').value

  if (!email || !password) {
    alert('Please fill in all fields.')
  } else if (password.length &lt; 8) {
    alert('Your password must be at least 8 characters long.')
  } else {
    alert('Form submitted successfully!')
  }
})

This code will validate a form’s email and password fields when the form is submitted. If either field is empty, the code will display an alert message prompting the user to fill in all fields. If the password field is less than 8 characters long, the code will display an alert message prompting the user to enter a password that is at least 8 characters long. If the form passes validation, the code will display an alert message indicating that the form was submitted successfully.

In conclusion, JavaScript is a powerful tool that can be used to enhance the UX and UI of your website. By using these JavaScript snippets, you can create a more engaging and user-friendly experience for your users. However, it is important to use these JavaScript snippets wisely and sparingly to ensure that they do not negatively impact the performance of your website.

A Guide to Choosing the Best Color Method for Web Design

When it comes to web design, color is a crucial element that can make or break the overall user experience. While there are several ways to define colors in web design, three of the most popular methods are HSL, RGBA, and hex codes. In this article, we will compare the pros and cons of each color method and provide code examples to help you make an informed decision when choosing which method to use.

UNLIMITED DOWNLOADS: 400,000+ Fonts & Design Assets

Starting at only $16.50 per month!

HSL Color

HSL stands for Hue, Saturation, and Lightness. This color model is based on the color wheel and allows you to define colors by their hue (color), saturation (intensity), and lightness (brightness). HSL colors are defined in CSS using the following syntax: hsl(hue, saturation, lightness).

Pros:

One of the biggest advantages of using HSL colors is that they are incredibly flexible. With HSL, you can easily adjust the hue, saturation, and lightness of a color to create a wide range of different shades and tones. This makes it easy to create a cohesive color palette for your website.

Another advantage of using HSL is that it is easy to read and understand. The values are intuitive, and the syntax is straightforward, making it easy to write and modify code.

Cons:

One of the main disadvantages of using HSL is that it can be challenging to match colors across different devices and browsers. While HSL is designed to be device-independent, there can be subtle differences in how colors are rendered on different screens.

Another disadvantage of using HSL is that it can be difficult to remember the exact values of specific colors. While this is not a major issue for small projects, it can become a problem when working on larger websites with many different colors.

Example:

body {
  background-color: hsl(240, 100%, 50%);
  color: hsl(0, 0%, 20%);
}

RGBA Color

RGBA stands for Red, Green, Blue, and Alpha. This color model is similar to RGB, but with the addition of an alpha channel that defines the opacity of a color. RGBA colors are defined in CSS using the following syntax: rgba(red, green, blue, alpha).

Pros:

One of the biggest advantages of using RGBA is that it allows you to control the opacity of a color. This can be useful when designing overlays, shadows, and other visual effects that require transparency.

Another advantage of using RGBA is that it is supported by all modern browsers, including Internet Explorer 9 and later.

Cons:

One of the main disadvantages of using RGBA is that it can be more challenging to create a cohesive color palette. Because you are defining each color channel separately, it can be more challenging to create harmonious color combinations.

Another disadvantage of using RGBA is that it can be more difficult to read and understand the code. The values are not as intuitive as HSL, and the syntax can be more complicated.

Example:

body {
  background-color: rgba(255, 0, 0, 0.5);
  color: rgba(0, 0, 255, 0.75);
}

Hex Code Color

Hex code colors are a way of representing colors using hexadecimal notation. This method of color definition is based on the RGB color model and uses a combination of six characters to represent each color channel. Hex code colors are defined in CSS using the following syntax: #RRGGBB.

Pros:

One of the main advantages of using hex code colors is that they are easy to use and remember. Once you are familiar with the syntax, you can quickly and easily define any color you need. Additionally, hex code colors are widely supported by all modern browsers and devices.

Another advantage of using hex code colors is that they can be used to define a wide range of colors, including shades and tones. By manipulating the values of each color channel, you can create a virtually unlimited number of colors.

Cons:

One of the main disadvantages of using hex code colors is that it can be challenging to adjust the saturation and lightness of a color. Because hex code colors are based on the RGB color model, adjusting the saturation and lightness requires complex calculations that can be time-consuming.

Another disadvantage of using hex code colors is that they can be challenging to read and understand, especially for beginners. The values are not intuitive, and it can be difficult to remember the exact values of specific colors.

Example:

body {
  background-color: #ff0000;
  color: #0000ff;
}

When it comes to choosing which color method to use in web design, there is no one-size-fits-all answer. Each method has its pros and cons, and the best choice depends on the specific project’s requirements and the designer’s personal preference. In general, HSL is an excellent choice for designers looking for flexibility and easy-to-read code. RGBA is a good choice for designers looking for control over opacity, while hex code colors are a good choice for designers looking for ease of use and compatibility across all devices and browsers.

Regardless of which method you choose, remember that color is a crucial element in web design. Make sure to carefully consider the color palette you use and how it affects the overall user experience. By using the right color method and carefully selecting your colors, you can create a beautiful and engaging website that your users will love.

Mastering CSS Variables and Unlocking Their Full Potential

CSS Variables, also known as Custom Properties, have revolutionized the way we manage styles and build maintainable, flexible stylesheets. They enable developers to store and reuse values throughout a stylesheet, making it easier to change themes, colors, fonts, and more with just a few updates. In this article, we’ll explore the best practices for using CSS variables, along with some helpful code examples.

Your Designer Toolbox Unlimited Downloads: 500,000+ Web Templates, Icon Sets, Themes & Design Assets

1. Defining and Using CSS Variables

To define a CSS variable, you must use the double hyphen (–) syntax. Typically, you’ll want to create your variables within the :root pseudo-class, which refers to the highest-level parent element in the DOM tree. This ensures that your variables are globally accessible.

:root {
  --primary-color: #3498db;
  --secondary-color: #2ecc71;
  --font-size: 16px;
}

body {
  font-size: var(--font-size);
}

a {
  color: var(--primary-color);
}

button {
  background-color: var(--secondary-color);
}

In the example above, we’ve defined three CSS variables: –primary-color, –secondary-color, and –font-size. To use these variables, we use the var() function, which accepts the variable name as its argument.

2. Fallback Values

One of the great features of CSS variables is their ability to provide a fallback value. This is helpful when a variable may not be defined or supported by a particular browser. To provide a fallback value, include a second argument within the var() function.

body {
  font-size: var(--font-size, 16px);
}

In this example, if the –font-size variable isn’t defined, the browser will use the fallback value of 16px.

3. Leveraging Variables in Media Queries and Theming

CSS variables are incredibly useful when combined with media queries and theming. You can quickly and easily update your styles for different devices or themes by redefining the variable values.

:root {
  --font-size: 16px;
}

@media screen and (min-width: 768px) {
  :root {
    --font-size: 18px;
  }
}

body {
  font-size: var(--font-size);
}

In this example, we’ve updated the –font-size variable within a media query. When the screen width is at least 768px, the font size will automatically adjust to 18px.

4. Working with Calculated Values

CSS variables can be combined with the calc() function to create dynamic and flexible values.

:root {
  --base-padding: 10px;
}

.container {
  padding: calc(var(--base-padding) * 2);
}

In the example above, we’ve defined a base padding value and used it in combination with the calc() function to double the padding for the .container element.

5. Handling Colors with HSL and CSS Variables

When working with colors, using the HSL color format in combination with CSS variables makes it easier to create color schemes and adjust hues, saturation, and lightness.

:root {
  --primary-hue: 210;
  --primary-color: hsl(var(--primary-hue), 50%, 50%);
  --primary-color-light: hsl(var(--primary-hue), 50%, 75%);
  --primary-color-dark: hsl(var(--primary-hue), 50%, 25%);
}

a {
  color: var(--primary-color);
}

a:hover {
  color: var(--primary-color-light);
}

a:active {
  color: var(--primary-color-dark);
}

In this example, we’ve used the HSL color format and CSS variables to create a primary color and its lighter and darker variations. By adjusting the –primary-hue value, you can change the color scheme throughout your stylesheet with ease.

6. JavaScript Interoperability

CSS variables can be accessed and manipulated using JavaScript, providing an additional layer of flexibility and dynamism. For instance, you can create user-customizable themes by modifying variables through JavaScript.

<button onclick="changeTheme()">Change Theme</button>

<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%3E%0A%20%20function%20changeTheme()%20%7B%0A%20%20%20%20let%20root%20%3D%20document.documentElement%3B%0A%20%20%20%20let%20currentHue%20%3D%20parseInt(root.style.getPropertyValue('--primary-hue'))%3B%0A%20%20%20%20let%20newHue%20%3D%20(currentHue%20%2B%2030)%20%25%20360%3B%0A%20%20%20%20root.style.setProperty('--primary-hue'%2C%20newHue)%3B%0A%20%20%7D%0A%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="&lt;script&gt;" title="&lt;script&gt;" />

In the example above, clicking the “Change Theme” button will change the –primary-hue variable, effectively updating the primary color and its variations.

Wrapping Up

Variables have transformed the way we approach theming, responsiveness, and maintainability in our stylesheets. By following best practices such as global variable declaration, using fallback values, leveraging variables in media queries, working with calculated values, handling colors with HSL, and harnessing JavaScript interoperability, you’ll unlock their full potential.

With this newfound understanding, you can create more efficient, flexible, and dynamic stylesheets that adapt to different devices, user preferences, and themes with minimal effort.

How AI Can Be Used For Web Development

AI, or artificial intelligence, has brought about significant improvements in the world of web development recently. By automating repetitive and mundane tasks, as well as finding solutions more efficiently, AI can help developers save time and effort, allowing them to focus on more creative and complex aspects of web development.

Overall, AI has the potential to transform web development and make it faster, more efficient, and more user-friendly. As the technology continues to evolve, we can expect to see even more innovative use cases of AI in web development. However, it’s important to note that AI is not a substitute for human creativity and expertise. While AI can automate or speed up many tasks, it cannot replace the creativity and insight that human developers bring to the table. AI should be seen as a tool that can assist developers, rather than a replacement for them.

In this post, we’re going to explore some of the ways that AI (specifically ChatGPT) can be used right now in your web development workflow.

Your Web Designer Toolbox

Unlimited Downloads: 500,000+ Web Templates, Icon Sets, Themes & Design Assets Starting at only $16.50/month!

1. Coding

This is one of the primary benefits of AI that we’ve found to date: using ChatGPT to write actual code for your project. It’s been demonstrated that the tool can correctly create an entire WordPress plugin or custom block in a matter of minutes! We’ve put this to the test several times over the past couple months with varied results, depending on how complex the task. Most of the time it took several adjustments in our prompts, as well as some back and forth, trial and error, before ending up with something that was a viable solution, and yet it still took significantly less time than if we were to start from scratch and code it ourselves. In short, our experiments left us impressed!

We’ve also used the same tool to write JavaScript, jQuery, and other code snippets that have worked pretty well – again, most of the time. One major caveat to keep in mind is that the data that ChatGPT is relying on is dated back to 2021, so anything that requires newer properties or functions will likely not work, or need adjustments to be made to whatever solutions it provides. Still, a lot of time can be saved here.

2. Troubleshooting and Debugging

In a similar vein to the previous point, ChatGPT can help you out when you get stuck. We’ve found ourselves choosing it as our go to now rather than searching for a solution on the various dev forums. Drop your troubled code in, explain the error or problem you’re having, and get some solid guidance quickly.

3. Placeholder Content

Move on from using nonsensical placeholder content while waiting for your client to provide the real thing. Instead, you can ask ChatGPT to write up some About or Contact page copy, or even a series of blog posts that, while they would not suffice in a production environment, they will at least give a more realistic feel and presentation to the project than lipsum. Note that we don’t recommend using AI for actual content production, as it lacks the human tone needed for a genuinely authentic website.

4. Client Communications

Any time your communications with a client start heading in a potentially heated direction, you can use ChatGPT to help you compose a professional, objective, and rational response. Simply explaining the situation and asking how you should respond will give you some insight into how clearer heads may prevail, and therefore keep your relationship with your client moving in a positive and lasting direction.

5. Content Creation and SEO

Again, we don’t recommend using ChatGPT to actually write content for your projects, but it can definitely provide you with topics, outlines, and ideas. It can also be really useful to provide keywords, meta descriptions, and other SEO elements for your pages.

How Are You Using AI in Web Development?

Are you currently incorporating AI into your web development workflow? Are you using it in ways other than what we’ve shared here? Hit us up on Twitter or send us a message and let us know – we’d love to hear how it’s making your job easier, and we’re excited to see where we go next with this exciting technology!

How To Get The X and Y Position of HTML Elements in JavaScript and jQuery

When developing web applications, it may be necessary to get the X and Y position of HTML elements on the page for a variety of purposes, such as positioning other elements relative to the target element or triggering events based on the element’s location. In this article, we will explore how to get the X and Y position of HTML elements in JavaScript and jQuery.

The Freelance Designer Toolbox

Unlimited Downloads: 500,000+ Web Templates, Icon Sets, Themes & Design Assets All starting at only $16.50 per month

 

Getting the X and Y Position in JavaScript

To get the X and Y position of an HTML element in JavaScript, we can use the getBoundingClientRect() method. This method returns an object with properties that describe the position of the element relative to the viewport.

Here’s an example of how to get the X and Y position of an element with the ID “myElement” using JavaScript:

const element = document.getElementById('myElement');
const rect = element.getBoundingClientRect();
const x = rect.left + window.scrollX;
const y = rect.top + window.scrollY;

In this example, we first get a reference to the element using getElementById(). We then call the getBoundingClientRect() method on the element, which returns an object with properties such as left, top, right, and bottom. The left and top properties describe the X and Y position of the element relative to the viewport.

Note that the left and top properties returned by getBoundingClientRect() are relative to the top-left corner of the viewport, not the top-left corner of the document. To get the absolute position of the element, we need to add the current scroll position of the window to the left and top values using window.scrollX and window.scrollY, respectively.

Getting the X and Y Position in jQuery

In jQuery, we can use the offset() method to get the X and Y position of an HTML element. This method returns an object with properties that describe the position of the element relative to the document.

Here’s an example of how to get the X and Y position of an element with the ID “myElement” using jQuery:

const element = $('#myElement');
const x = element.offset().left;
const y = element.offset().top;

In this example, we first get a reference to the element using the jQuery selector $('#myElement'). We then call the offset() method on the element, which returns an object with properties such as left and top. The left and top properties describe the X and Y position of the element relative to the document.

Note that the offset() method returns the position of the element relative to the document, not the viewport. If you want to get the position of the element relative to the viewport, you can subtract the current scroll position of the window using $(window).scrollLeft() and $(window).scrollTop(), respectively. Here’s an example:

const element = $('#myElement');
const offset = element.offset();
const x = offset.left - $(window).scrollLeft();
const y = offset.top - $(window).scrollTop();

Like the previous example, we first get a reference to the element using the jQuery selector $('#myElement'), then call the offset() method on the element, which returns an object with properties such as left and top. The left and top properties describe the X and Y position of the element relative to the document.

The, to get the position of the element relative to the viewport, we subtract the current scroll position of the window using $(window).scrollLeft() and $(window).scrollTop(), respectively. This gives us the X and Y position of the element relative to the viewport.

Note that the scrollLeft() and scrollTop() methods return the number of pixels that the document is currently scrolled from the left and top edges, respectively. Subtracting these values from the offset of the element gives us its position relative to the viewport.

Quick Tip: How To Disable Autocomplete on Form Inputs

Autocomplete is a feature that can save users’ time by suggesting previously entered information when filling out forms. Although it can be a helpful feature, sometimes it can be a privacy concern, especially when users share devices or work on public computers. In this case, users may want to disable the autocomplete feature for specific input fields or forms. In this article, we will discuss how to disable autocomplete for input elements.

UNLIMITED DOWNLOADS: 1,500,000+ Icons & Design Assets

 

The autocomplete attribute

The autocomplete attribute is used to control this feature. This attribute can be applied to different form elements, including input tags. It takes two values: “on” and “off.” By default, the browser sets the value to “on” for input tags. When set to “off,” the browser will not suggest previously entered values for that particular input field.

Disabling autocomplete for a specific input field

To disable auto-complete for a specific input field, you can use the following code:

<input type="text" name="username" autocomplete="off">

In the above code, we have added the autocomplete attribute to an input tag and set its value to “off.” This will disable it for that particular input field. You can apply this attribute to other input tags as well, including password fields, email fields, and search fields.

Disabling autocomplete for a whole form

If you want to disable it for a whole form, you can add the attribute to the form element and set its value to “off.” The following code demonstrates this:

<form method="post" action="/submit-form" autocomplete="off">
  <input type="text" name="username">
  <input type="password" name="password">
  <input type="email" name="email">
  <button type="submit">Submit</button>
</form>

In the above code, we have added the autocomplete attribute to the form element and set its value to “off.” This will disable it for all the input fields within the form.

Best practices

When disabling autocomplete, it is essential to keep in mind that it can impact the user experience. Some users may appreciate the feature, as it can save time and make filling out forms easier. Therefore, it is recommended to disable it only when necessary, such as when the user is working on a public computer.

Another best practice is to use the attribute only for specific input fields, such as search fields or email fields, to provide a better user experience.

CSS Basics: Visibility: Hidden vs. Display: None

visibility: hidden and display: none are two CSS properties that can be used to hide elements. While they may seem similar at first glance, there are some significant differences between them. In this article, we’ll explore these differences and provide some examples to illustrate their use.

The UX Designer Toolbox

Unlimited Downloads: 500,000+ Wireframe & UX Templates, UI Kits & Design Assets Starting at only $16.50 per month!

 

visibility: hidden

The visibility property in CSS determines whether or not an element is visible on the web page. If set to hidden, the element will be hidden from view, but it will still occupy space on the page. This means that any other elements that would normally be positioned after it will still be positioned as if the hidden element were still visible.

Here’s an example of how visibility: hidden works:

<!DOCTYPE html>
<html>
  <head>
    <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cstyle%3E%0A%20%20%20%20%20%20%23hidden-element%20%7B%0A%20%20%20%20%20%20%20%20visibility%3A%20hidden%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%3C%2Fstyle%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="&lt;style&gt;" title="&lt;style&gt;" />
  </head>
  <body>
    <p>This is some text before the hidden element.</p>
    <div id="hidden-element">
      <p>This element is hidden using visibility.</p>
    </div>
    <p>This is some text after the hidden element.</p>
  </body>
</html>

In this example, the #hidden-element is hidden using visibility: hidden. Notice that the element still occupies space on the page, and the text after it is still positioned as if it were visible.

display: none

The display property in CSS determines how an element is displayed on the web page. If set to none, the element will be completely removed from the page and will not occupy any space. This means that any other elements that would normally be positioned after it will be repositioned as if the hidden element were not present.

Here’s an example of how display: none works:

<!DOCTYPE html>
<html>
  <head>
    <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cstyle%3E%0A%20%20%20%20%20%20%23hidden-element%20%7B%0A%20%20%20%20%20%20%20%20display%3A%20none%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%3C%2Fstyle%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="&lt;style&gt;" title="&lt;style&gt;" />
  </head>
  <body>
    <p>This is some text before the hidden element.</p>
    <div id="hidden-element">
      <p>This element is hidden using display.</p>
    </div>
    <p>This is some text after the hidden element.</p>
  </body>
</html>

In this example, the #hidden-element is hidden using display: none. Notice that the element does not occupy any space on the page, and the text after it is repositioned as if the element were not present.

When to use visibility: hidden vs. display: none

Now that we’ve seen how visibility: hidden and display: none work, it’s important to consider when to use one over the other.

Use visibility: hidden when you want to hide an element from view but still want it to occupy space on the page. This can be useful when you want to reveal the element later or when you want to maintain the layout of the page.

Use display: none when you want to completely remove an element from the page and don’t want it to occupy any space. This can be useful when you want to completely hide an element and don’t plan to reveal it later.

How To Use CSS To Maintain Aspect Ratio For Responsive Design

Maintaining the aspect ratio of a div is a common requirement when creating responsive web designs. In this article, we’ll explore how to use CSS to maintain the aspect ratio of a div as the window’s width changes.

To achieve this, we’ll use the padding hack. The padding hack is a technique that uses a percentage value for padding-top or padding-bottom to maintain the aspect ratio of an element. The percentage value is calculated based on the width of the parent element. As the width of the parent element changes, the padding value will adjust to maintain the aspect ratio of the child element.

Your Web Designer Toolbox
Unlimited Downloads: 500,000+ Web Templates, Icon Sets, Themes & Design Assets


 

Let’s start by creating a div element with a background color.

<div class="aspect-ratio"></div>

<style>
  .aspect-ratio {
    background-color: #ccc;
  }
</style>

To maintain the aspect ratio of this div, we’ll set its padding-top to a percentage value. The percentage value will be calculated based on the desired aspect ratio of the div. For example, if we want the aspect ratio to be 16:9, we’ll set the padding-top to 56.25% (9/16 * 100).

.aspect-ratio {
  background-color: #ccc;
  padding-top: 56.25%;
}

Now, as the width of the parent element changes, the padding value will adjust as desired.

Here’s an example that shows how to use the padding hack on a div with a background image.

<div class="aspect-ratio" style="background-image: url('image.jpg')"></div>

<style>
  .aspect-ratio {
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    position: relative;
  }
  
  .aspect-ratio:before {
    content: "";
    display: block;
    padding-top: 56.25%;
  }
  
  .aspect-ratio > * {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
  }
</style>

In this example, we are again using the padding hack, and we’re also using a pseudo-element (:before) to create the padding. We’re setting the position of the parent element to relative and the position of the child element to absolute to position the child element inside the parent element. We’re also setting the width and height of the child element to 100% to fill the parent element.

In conclusion, the padding hack is a simple and effective technique for maintaining the aspect ratio of a div as the window’s width changes. By using a percentage value for padding-top or padding-bottom, we can calculate the padding value based on the desired aspect ratio of the div. This technique is widely used in responsive web design and can be used to create a variety of layouts and designs. Be sure to check out our library of CSS articles and tutorials while you’re here!

How To Align Checkboxes and Their Labels Consistently Across Browsers

While checkboxes are relatively straightforward to implement, aligning them with their labels can be a challenge, as each browser renders them differently. In this article, we will explain how to align checkboxes and their labels consistently across all browsers using CSS.

UNLIMITED DOWNLOADS: 500,000+ WordPress & Design Assets

Sign up for Envato Elements and get unlimited downloads starting at only $16.50 per month!

 

Wrap the Checkbox and Label in a Container

The first step is to wrap the elements in a container so we can use it to apply styling to both the checkbox and the label.

<div class="checkbox-container">
  <input type="checkbox" id="checkbox1">
  <label for="checkbox1">Checkbox Label</label>
</div>

Style the Checkbox and Label

Once we have our container, we can use CSS to position the checkbox and label, adjust their size, and style them.

.checkbox-container {
  display: flex;
  align-items: center;
}

.checkbox-container input[type="checkbox"] {
  margin-right: 10px;
}

.checkbox-container label {
  margin: 0;
}

The display: flex; property allows us to align the checkbox and label vertically. The align-items: center; property centers the checkbox and label vertically within the container.

The margin-right: 10px; property adds a small amount of space between the checkbox and the label. The margin: 0; property removes any margin that may be added by default by the browser.

Styling the Checkbox to make it visually appealing

In addition to aligning the checkbox and label, we can also style the checkbox to make it more visually appealing.

.checkbox-container input[type="checkbox"] {
  appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid #ccc;
  border-radius: 4px;
  background-color: #fff;
  cursor: pointer;
}

.checkbox-container input[type="checkbox"]:checked {
  background-color: #007bff;
  border-color: #007bff;
}

.checkbox-container input[type="checkbox"]:checked::before {
  content: "\2713";
  font-size: 16px;
  color: #fff;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

The appearance: none; property removes the default styling of the checkbox, allowing us to create our own custom style. The width and height properties set the size of the checkbox. The border property creates a border around the checkbox, and the border-radius property rounds the corners of the checkbox.

The background-color property sets the background color of the checkbox, and the cursor: pointer; property changes the cursor to a pointer when the user hovers over the checkbox.

The input[type="checkbox"]:checked selector styles the checkbox when it is checked. The background-color property changes the background color of the checkbox, and the border-color property changes the color of the border.

The input[type="checkbox"]:checked::before pseudo-element adds a checkmark to the checkbox when it is checked. The content property adds the checkmark character, and the font-size property sets the size of the checkmark. The color property sets the color of the checkmark, and the position: absolute; property positions the checkmark in the center of the checkbox.

Conclusion

By wrapping checkboxes and their labels in a container and applying CSS styling, we can align checkboxes and their labels consistently across all browsers, as well as create a more visually appealing and user-friendly form element. Be sure to check out our other CSS articles while you’re here!

Beginners Guide To Getting Started With NPM

NPM, which stands for Node Package Manager, is a package manager for the JavaScript programming language. It provides a central repository for managing and sharing packages of code that can be used in a variety of projects. With NPM, developers can easily install, update, and manage packages without having to manually download and manage dependencies.

Your Web Designer Toolbox

Unlimited Downloads: 500,000+ Web Templates, Icon Sets, Themes & Design Assets Starting at only $16.50/month!

 

Getting Started with NPM

Before you can start using NPM, you need to have Node.js installed on your computer. You can download the latest version of Node.js from the official website (https://nodejs.org/).

Once you have Node.js installed, you can start using NPM by opening a terminal or command prompt window. You can then use the following command to check if it is installed:

npm -v

Creating a Package.json File

The first step in using NPM is to create a package.json file for your project. This file is used to manage your project’s dependencies, scripts, and metadata. You can create a package.json file by running the following command in your project’s directory:

npm init

Installing Packages

NPM makes it easy to install packages and add them to your project. You can install packages using the following command:

npm install <package_name>

For example, to install the lodash package, you would run the following command:

npm install lodash

The installed packages will be added to the dependencies section in your package.json file.

Using Packages in Your Project

Once you have installed a package, you can use it in your project by requiring it in your code. For example, to use the lodash package, you would add the following code to your project:

var _ = require(“lodash”);

Updating Packages

NPM makes it easy to keep your packages up-to-date. You can update all packages in your project by running the following command:

npm update

Or, you can update a specific package by running the following command:

npm update <package_name>

Uninstalling Packages

You can uninstall a package from your project by running the following command:

npm uninstall <package_name>

Conclusion

NPM is a powerful tool for managing packages and dependencies in your JavaScript projects. With its simple commands and centralized repository, this tool makes it easy for developers to install, update, and manage packages in their projects. By following the steps outlined in this article, you can get started using NPM today and start taking advantage of its many benefits.

Further reading

The Difference Between the :where() and :is() CSS Selectors

The CSS selectors :where() and :is() are two pseudo-classes that allow you to select elements based on their relationship with other elements. Although they sound similar, they are different in terms of functionality and syntax.

Your Web Designer Toolbox
Unlimited Downloads: 500,000+ Web Templates, Icon Sets, Themes & Design Assets


The :where() pseudo-class was introduced as part of the CSS Selectors Level 4 specification and allows you to select elements based on the presence of other elements that match a specific condition. In other words, you can select elements based on the relationship between elements in a DOM tree. For example, you can use the :where() selector to select a list item li only if it is the first child of an unordered list ul:

li:where(:first-child of ul) {
  background-color: yellow;
}

On the other hand, the :is() pseudo-class is part of the CSS Selectors Level 3 specification and allows you to select an element if it is one of several different selectors. It is similar to the logical OR operator, in CSS. For example, you can use the :is() selector to select a p element if it is either the first child of its parent or has a class of highlight:

p:is(:first-child, .highlight) {
  background-color: yellow;
}

It’s important to note that the :where() selector has better browser support than the :is() selector, and that the :is() selector should not be used in conjunction with the :not() pseudo-class.

What Is the JavaScript Equivalent To The PHP sleep() Function?

JavaScript does not have a direct equivalent to the PHP sleep() function, which pauses the execution of a script for a specified number of seconds. However, there are a few ways to achieve similar functionality in JavaScript.

UNLIMITED DOWNLOADS: Email, admin, landing page & website templates

Starting at only $16.50 per month!

 

Using setTimeout()

The setTimeout() function is a built-in JavaScript function that allows you to run a piece of code after a specified amount of time. You can use it to create a delay in your script. Here’s an example:

console.log('Before Sleep');
setTimeout(() => {
  console.log('After Sleep');
}, 3000);

In the example above, the console.log('Before Sleep') statement will be executed immediately, followed by a 3-second delay, after which the console.log('After Sleep') statement will be executed.

Using async/await

Another way to create a delay in JavaScript is to use the async/await syntax. With async/await, you can write asynchronous code that runs in a way that is similar to synchronous code. For example:

async function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

async function main() {
  console.log('Before Sleep');
  await sleep(3000);
  console.log('After Sleep');
}

main();

In this example, we’ve created an async function called sleep that returns a Promise that resolves after a specified amount of time. The main function uses the await keyword to wait for the sleep function to complete, effectively creating a 3-second delay.

Note that async/await is only supported in modern browsers and requires a runtime with support for Promises.

Both of these methods can be used to achieve a similar result to the PHP sleep() function, but with different syntax and limitations. Choose the method that works best for your use case.

Further reading.

How To Get a User’s IP Address With PHP

In PHP, there are several methods to retrieve a user’s IP address. We will explore two of those ways in this article.

UNLIMITED DOWNLOADS: 500,000+ WordPress & Design Assets

Sign up for Envato Elements and get unlimited downloads starting at only $16.50 per month!

 

The most reliable way to get a user’s IP address in PHP is to use the $_SERVER superglobal variable.

The $_SERVER superglobal variable contains information about the server environment, including the user’s IP address. Here’s an example:

<?php
$ip = $_SERVER['REMOTE_ADDR'];
echo $ip;
?>

The $_SERVER['REMOTE_ADDR'] element returns the IP address of the client (i.e., the user’s device) that is making the request to the server. This method works well for most cases, but there are a few situations where it may not return the correct IP address, such as when the user is behind a proxy server or using a VPN.

To handle these cases, it is recommended to use the following code to get the user’s IP address:

<?php
function get_client_ip() {
    $ip = '';
    if (isset($_SERVER['HTTP_CLIENT_IP'])) {
        $ip = $_SERVER['HTTP_CLIENT_IP'];
    } elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
        $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
    } else {
        $ip = $_SERVER['REMOTE_ADDR'];
    }
    return $ip;
}

$ip = get_client_ip();
echo $ip;
?>

In this code, we first check if the $_SERVER['HTTP_CLIENT_IP'] element is set. If it is, we use its value as the user’s IP address. If not, we then check if the $_SERVER['HTTP_X_FORWARDED_FOR'] element is set. If it is, we use its value as the user’s IP address. If neither of these elements is set, we use the $_SERVER['REMOTE_ADDR'] element as the user’s IP address.

This method provides a more robust solution for retrieving the user’s IP address, as it takes into account the possibility that the user may be behind a proxy server or using a VPN.

Learn more here.

Quick Tip: How To Disable Resizing of a Textarea in HTML or CSS

In this quick tip, we’re going to show you 2 different ways to disable the resizing of a textarea, for those times when you don’t want the user to be able to control it in this manner. It’s a relatively quick process, with just some simple CSS using the resize CSS property.

Your Designer Toolbox Unlimited Downloads: 500,000+ Web Templates, Icon Sets, Themes & Design Assets

 

HTML

The HTML textarea element provides a resizable property by default. To disable it, you can use the CSS property resize: none in the textarea element. Here is an example:

 <textarea style="resize: none;"></textarea> 

CSS

You can also disable the resizable property of a textarea by using CSS that is not inline. You can add a class to the textarea element and then add the CSS property resize: none to the class. Here is an example:

<textarea class="no-resize"></textarea>

<style>
  .no-resize {
    resize: none;
  }
</style>