{"id":270,"date":"2025-03-04T17:12:36","date_gmt":"2025-03-04T17:12:36","guid":{"rendered":"https:\/\/emmab.uk\/blog\/?p=270"},"modified":"2025-03-07T16:04:25","modified_gmt":"2025-03-07T16:04:25","slug":"seminar-article","status":"publish","type":"post","link":"https:\/\/emmab.uk\/blog\/2025\/03\/04\/seminar-article\/","title":{"rendered":"CSS Scroll Snapping"},"content":{"rendered":"\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<p class=\"has-text-align-left has-primary-color has-text-color has-link-color wp-elements-f0aadb2e1b1637bba3f2ef491d5387ba\" style=\"font-size:20px\">Welcome to my seminar tutorial, where I will I&#8217;ll be giving you all the information you need to use CSS scroll snapping in your websites, and improve your user&#8217;s experience. You can also view and download my powerpoint presentation <a href=\"https:\/\/www.canva.com\/design\/DAGfSCG1Kfg\/3I6tLu8Hgw4rZ-50uFGXUA\/view\" data-type=\"link\" data-id=\"https:\/\/www.canva.com\/design\/DAGfSCG1Kfg\/3I6tLu8Hgw4rZ-50uFGXUA\/view\">here<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"font-size:60px\">The basics<\/h2>\n<\/div><\/div>\n\n\n\n<details style=\"opacity: 0;\" superb-addons-animation=\"fadeIn\" class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>What is CSS Scroll Snapping?<\/summary>\n<p style=\"font-size:20px\">Scroll Snapping is a feature in CSS that allows you to lock the viewport to specific elements when scrolling. <\/p>\n\n\n\n<p>It helps improve the user experience by providing a smoother and predictable scrolling experience, specifically for users with motor impairments. <\/p>\n\n\n\n<p>It also ehances erformance optimisation by reducing reliance on JavaScript which shrinks the site size and improves page load times.<\/p>\n<\/details>\n\n\n\n<h2 class=\"wp-block-heading has-primary-color has-text-color has-link-color wp-elements-8bf2a67d4f9d6698e972b0c703940a96\" style=\"font-size:50px\">The Properties<\/h2>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>The Key Properties<\/summary>\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow\">\n<pre class=\"wp-block-code has-subtle-background-background-color has-background has-small-font-size\"><code><strong>scroll-snap-type<\/strong>:\n\napplied the parent elements &amp; controls scroll snapping behaviour\n\n<\/code><\/pre>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<pre class=\"wp-block-code has-subtle-background-background-color has-background has-small-font-size\"><code><strong>scroll-snap-align<\/strong>:\n\napplied to child elements &amp; is used to determine the snap point (where the content should snap)\n<\/code><\/pre>\n<\/div>\n<\/div>\n\n\n\n<p>Each property has four different values with different effects:<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow\">\n<pre class=\"wp-block-code has-subtle-background-background-color has-background has-small-font-size\"><code><strong>scroll-snap-type<\/strong>:\n\n<strong>X<\/strong> - horizontal snap\n\n<strong>Y<\/strong> - vertical snap\n\n<strong>mandatory <\/strong>- forces content to snap at a specific point\n\n<strong>promixity<\/strong> - content will snap into place when close to the snap points\n<\/code><\/pre>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<pre class=\"wp-block-code has-subtle-background-background-color has-background has-small-font-size\"><code><strong>scroll-snap-align<\/strong>:\n\n<strong>start<\/strong> - snaps at the start of the element\n\n<strong>center<\/strong> - snaps at the center of the element \n\n<strong>end<\/strong> - snaps at the end of the element \n\n<strong>none<\/strong> - stops content from snapping into view<\/code><\/pre>\n<\/div>\n<\/div>\n\n\n\n<p><strong>Note:<\/strong> you can pair the values X &amp; Y with mandatory and\/or proximity (e.g., <strong>scroll-snap-type<\/strong>: y mandatory;)<\/p>\n<\/details>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>The Additional Properties<\/summary>\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<pre class=\"wp-block-code has-subtle-background-background-color has-background\"><code><strong>scroll-padding:<\/strong>\n\nsets the padding within the scroll container<\/code><\/pre>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<pre class=\"wp-block-code has-subtle-background-background-color has-background\"><code><strong>scroll-margin:<\/strong>\n\nadds space around the snap are<\/code><\/pre>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<pre class=\"wp-block-code has-subtle-background-background-color has-background\"><code><strong>scroll-snap-stop<\/strong>:\n\nSpecifies whether the scroll container should force a snap on the next page <strong>(always)<\/strong> or the last page <strong>(none) <\/strong>when a user scrolls too fast. Useful for users on mobile devices.<\/code><\/pre>\n<\/div>\n<\/div>\n<\/details>\n<\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"font-size:50px\">Implementation<\/h2>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>Step By Step Guide<\/summary>\n<h5 class=\"wp-block-heading\">Step 1: The HTML<\/h5>\n\n\n\n<p>To set up HTML for CSS Scroll Snap, you&#8217;ll need to create a container with child elements that will snap into place the user scrolls. Below is a simple example that demonstrates how to structure your HTML for a slideshow. If you already have your own HTML code, feel free to use it.<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<pre class=\"wp-block-code has-subtle-background-background-color has-background\"><code>&lt;html&gt;\n&lt;section&gt; \n  &lt;h2&gt;First slide&lt;\/h2&gt;\n&lt;\/section&gt;\n&lt;section&gt;\n  &lt;h2&gt;Second Slide&lt;\/h2&gt;\n&lt;section&gt;\n  &lt;h2&gt;Third slide&lt;\/h2&gt;\n&lt;\/section&gt;\n&lt;\/html&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow\">\n<p>In this example, &lt;html&gt; is the container element and &lt;section&gt;is the child element.<\/p>\n<\/div>\n<\/div>\n\n\n\n<h5 class=\"wp-block-heading\">Step 2: The CSS<\/h5>\n\n\n\n<p>Once your HTML is set up, it&#8217;s time to define your scoll snap type and your snap point.<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<pre class=\"wp-block-code has-subtle-background-background-color has-background\"><code>html{\n  <strong>scroll-snap-type<\/strong>:y mandatory;\n}<\/code><\/pre>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow\">\n<p>In this example, I am using &#8216;y mandatory&#8217; as I want the content to force a snap on the y axis.<\/p>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<pre class=\"wp-block-code has-subtle-background-background-color has-background\"><code>section {\n  <strong>scroll-snap-align:<\/strong>start;\n  <strong>scroll-snap-stop:<\/strong>always;\n}<\/code><\/pre>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow\">\n<p>I&#8217;ve used the value &#8216;start&#8217; so that the snap point is at the start of every child element, and &#8216;always&#8217; has been used to always take the user the next page when scrolling.<\/p>\n<\/div>\n<\/div>\n\n\n\n<h5 class=\"wp-block-heading\">Step 3:The Result<\/h5>\n\n\n\n<p class=\"codepen\" data-height=\"300\" data-default-tab=\"html\" data-slug-hash=\"xbxrgdK\" data-pen-title=\"css scroll snap 2\" data-editable=\"true\" data-user=\"Emmanuella-Nziza\" style=\"height: 300px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;\">\n  <span>See the Pen <a href=\"https:\/\/codepen.io\/Emmanuella-Nziza\/pen\/xbxrgdK\">\n  css scroll snap 2<\/a> by Emmanuella Nziza (<a href=\"https:\/\/codepen.io\/Emmanuella-Nziza\">@Emmanuella-Nziza<\/a>)\n  on <a href=\"https:\/\/codepen.io\">CodePen<\/a>.<\/span>\n<\/p>\n<script async src=\"https:\/\/public.codepenassets.com\/embed\/index.js\"><\/script>\n<\/details>\n<\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Practical Applications<\/h2>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>Examples<\/summary>\n<h5 class=\"wp-block-heading\">1. Images galleries<\/h5>\n\n\n\n<p><strong>Credit:<\/strong> @argleink on Code Pen &#8211; <a href=\"https:\/\/codepen.io\/argyleink\/pen\/bGvoZpK\">https:\/\/codepen.io\/argyleink\/pen\/bGvoZpK<\/a><\/p>\n\n\n\n<p class=\"codepen\" data-height=\"300\" data-default-tab=\"html\" data-slug-hash=\"bGvoZpK\" data-pen-title=\"Snap Align - start, center, &amp;amp; end\" data-editable=\"true\" data-user=\"argyleink\" style=\"height: 300px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;\">\n  <span>See the Pen <a href=\"https:\/\/codepen.io\/argyleink\/pen\/bGvoZpK\">\n  Snap Align &#8211; start, center, &amp; end<\/a> by Adam Argyle (<a href=\"https:\/\/codepen.io\/argyleink\">@argyleink<\/a>)\n  on <a href=\"https:\/\/codepen.io\">CodePen<\/a>.<\/span>\n<\/p>\n<script async src=\"https:\/\/public.codepenassets.com\/embed\/index.js\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\">2. Carousels<\/h5>\n\n\n\n<p><strong>Credit:<\/strong> @Schepp on Code Pen &#8211; <a href=\"https:\/\/codepen.io\/Schepp\/pen\/WNbQByE\">https:\/\/codepen.io\/Schepp\/pen\/WNbQByE<\/a><\/p>\n\n\n\n<p class=\"codepen\" data-height=\"300\" data-default-tab=\"html\" data-slug-hash=\"WNbQByE\" data-pen-title=\"A CSS-only Carousel Slider\" data-editable=\"true\" data-user=\"Schepp\" style=\"height: 300px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;\">\n  <span>See the Pen <a href=\"https:\/\/codepen.io\/Schepp\/pen\/WNbQByE\">\n  A CSS-only Carousel Slider<\/a> by Christian Schaefer (<a href=\"https:\/\/codepen.io\/Schepp\">@Schepp<\/a>)\n  on <a href=\"https:\/\/codepen.io\">CodePen<\/a>.<\/span>\n<\/p>\n<script async src=\"https:\/\/public.codepenassets.com\/embed\/index.js\"><\/script>\n\n\n\n<h5 class=\"wp-block-heading\">3. Scrollable Stories<\/h5>\n\n\n\n<p><strong>Credit:<\/strong> @pxco on Code Pen &#8211; <a href=\"https:\/\/codepen.io\/pxco\/pen\/PoxpZEd\">https:\/\/codepen.io\/pxco\/pen\/PoxpZEd<\/a><\/p>\n\n\n\n<p class=\"codepen\" data-height=\"300\" data-default-tab=\"html\" data-slug-hash=\"PoxpZEd\" data-pen-title=\"scroll snap book\" data-editable=\"true\" data-user=\"pxco\" style=\"height: 300px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;\">\n  <span>See the Pen <a href=\"https:\/\/codepen.io\/pxco\/pen\/PoxpZEd\">\n  scroll snap book<\/a> by Paco (<a href=\"https:\/\/codepen.io\/pxco\">@pxco<\/a>)\n  on <a href=\"https:\/\/codepen.io\">CodePen<\/a>.<\/span>\n<\/p>\n<script async src=\"https:\/\/public.codepenassets.com\/embed\/index.js\"><\/script>\n\n\n\n<p><\/p>\n<\/details>\n\n\n\n<h2 class=\"wp-block-heading\">Browser Support<\/h2>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>Can I Use Summary<\/summary>\n<p>According to CanIUse.com, CSS scroll snap is compatible with nearly every browser, making it easy for developers to implement and improve their user experience. Click <a href=\"https:\/\/caniuse.com\/?search=css%20scroll%20snap\" data-type=\"link\" data-id=\"https:\/\/caniuse.com\/?search=css%20scroll%20snap\">here <\/a>for a more information. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/emmab.uk\/blog\/wp-content\/uploads\/2025\/03\/Screenshot-2025-03-06-at-18.43.06-1-1024x378.png\" alt=\"\" class=\"wp-image-325\"\/><\/figure>\n<\/details>\n\n\n\n<h5 class=\"wp-block-heading has-large-font-size\"><strong>References:<\/strong><\/h5>\n\n\n\n<p>Argyle, A. (2025, Jan 15).<em> CSS scroll-state()<\/em>. Chrome for Developers. <a href=\"https:\/\/developer.chrome.com\/blog\/css-scroll-state-queries\">https:\/\/developer.chrome.com\/blog\/css-scroll-state-queries<\/a><\/p>\n\n\n\n<p>Can I use. (n.d.). <em>CSS scroll snap<\/em>. <a href=\"https:\/\/caniuse.com\/?search=scroll%20snap\">https:\/\/caniuse.com\/?search=scroll%20snap<\/a><\/p>\n\n\n\n<p> Kohler, M. (2020, June 18). Practical CSS Scroll Snapping. CSS Tricks. <a href=\"https:\/\/css-tricks.com\/practical-css-scroll-snapping\/\">https:\/\/css-tricks.com\/practical-css-scroll-snapping\/<\/a><\/p>\n\n\n\n<p>Mozilla. (n.d.). <em>CSS scroll snap: Basic concepts<\/em>. MDN Web Docs. <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/CSS_scroll_snap\/Basic_concepts\">https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/CSS_scroll_snap\/Basic_concepts<\/a><\/p>\n\n\n\n<p>Web Dev Simplified. (2023, May 16). <em>Learn CSS Scroll Snap In 6 Minutes<\/em> [Video]. Youtube.<a href=\" https:\/\/www.youtube.com\/watch?v=ytl6TrroGis\"> https:\/\/www.youtube.com\/watch?v=ytl6TrroGis<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Welcome to my seminar tutorial, where I will I&#8217;ll be giving you all the information you need to use CSS scroll snapping in your websites, and improve your user&#8217;s experience. You can also view and download my powerpoint presentation here. The basics The Properties Implementation Practical Applications Browser Support References: Argyle, A. (2025, Jan 15). [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-270","post","type-post","status-publish","format-standard","hentry","category-content-management"],"_links":{"self":[{"href":"https:\/\/emmab.uk\/blog\/wp-json\/wp\/v2\/posts\/270","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/emmab.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/emmab.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/emmab.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/emmab.uk\/blog\/wp-json\/wp\/v2\/comments?post=270"}],"version-history":[{"count":15,"href":"https:\/\/emmab.uk\/blog\/wp-json\/wp\/v2\/posts\/270\/revisions"}],"predecessor-version":[{"id":326,"href":"https:\/\/emmab.uk\/blog\/wp-json\/wp\/v2\/posts\/270\/revisions\/326"}],"wp:attachment":[{"href":"https:\/\/emmab.uk\/blog\/wp-json\/wp\/v2\/media?parent=270"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/emmab.uk\/blog\/wp-json\/wp\/v2\/categories?post=270"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/emmab.uk\/blog\/wp-json\/wp\/v2\/tags?post=270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}