<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: OE Haruki</title>
    <description>The latest articles on DEV Community by OE Haruki (@oeharuki).</description>
    <link>https://dev.to/oeharuki</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2846763%2Fe57e4906-df0b-48d0-bc7b-fa15213369d8.jpg</url>
      <title>DEV Community: OE Haruki</title>
      <link>https://dev.to/oeharuki</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/oeharuki"/>
    <language>en</language>
    <item>
      <title>React vs Vue: A Comparative Guide to Basic Syntax</title>
      <dc:creator>OE Haruki</dc:creator>
      <pubDate>Tue, 11 Feb 2025 10:42:58 +0000</pubDate>
      <link>https://dev.to/oeharuki/react-vs-vue-a-comparative-guide-to-basic-syntax-2d91</link>
      <guid>https://dev.to/oeharuki/react-vs-vue-a-comparative-guide-to-basic-syntax-2d91</guid>
      <description>&lt;h2&gt;
  
  
  1. Introduction
&lt;/h2&gt;

&lt;p&gt;React and Vue.js are both highly popular libraries in frontend development. This article compares their basic syntax to help you understand their differences and choose the right tool for your project.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Component Creation
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Definition and Characteristics
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Vue.js
&lt;/h4&gt;

&lt;p&gt;Components are written in a file format consisting of &lt;code&gt;&amp;lt;template&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt;, and &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; sections. This clear separation of concerns improves code organization and development efficiency. Vue.js components can exchange data through parent-child relationships.&lt;/p&gt;

&lt;h4&gt;
  
  
  React
&lt;/h4&gt;

&lt;p&gt;Components are defined as functions or classes using JSX for UI description. JSX is a syntax that combines JavaScript and HTML, making UI construction more straightforward. React components exchange data through props.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Samples
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Vue.js
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;Hello, Vue!&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;MyComponent&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;style&lt;/span&gt; &lt;span class="na"&gt;scoped&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;/* Styles go here */&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;style&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  React
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;MyComponent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Hello, React!&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. State Management
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Definition and Characteristics
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Vue.js
&lt;/h4&gt;

&lt;p&gt;Uses the &lt;code&gt;data&lt;/code&gt; property to manage reactive data. The &lt;code&gt;data&lt;/code&gt; property manages component state, and when it changes, the UI automatically updates. Vue.js's reactive system detects data changes and automatically updates the UI.&lt;/p&gt;

&lt;h4&gt;
  
  
  React
&lt;/h4&gt;

&lt;p&gt;Uses the &lt;code&gt;state&lt;/code&gt; object, and in function components, utilizes the &lt;code&gt;useState&lt;/code&gt; hook. The &lt;code&gt;useState&lt;/code&gt; hook simplifies state management and updates. React's state management requires explicit state updates but makes state management more transparent.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Samples
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Vue.js
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;data&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;count&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  React
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Lifecycle Methods
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Definition and Characteristics
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Vue.js
&lt;/h4&gt;

&lt;p&gt;Uses lifecycle methods like &lt;code&gt;beforeCreate&lt;/code&gt;, &lt;code&gt;created&lt;/code&gt;, &lt;code&gt;beforeMount&lt;/code&gt;, &lt;code&gt;mounted&lt;/code&gt;, &lt;code&gt;beforeUpdate&lt;/code&gt;, &lt;code&gt;updated&lt;/code&gt;, &lt;code&gt;beforeDestroy&lt;/code&gt;, and &lt;code&gt;destroyed&lt;/code&gt;. These methods execute at different stages of a component's lifecycle to handle initialization, cleanup, and updates.&lt;/p&gt;

&lt;h4&gt;
  
  
  React
&lt;/h4&gt;

&lt;p&gt;Class components use methods like &lt;code&gt;componentDidMount&lt;/code&gt;, &lt;code&gt;componentDidUpdate&lt;/code&gt;, and &lt;code&gt;componentWillUnmount&lt;/code&gt;. Function components use the &lt;code&gt;useEffect&lt;/code&gt; hook. The &lt;code&gt;useEffect&lt;/code&gt; hook manages side effects and executes based on component lifecycle.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Samples
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Vue.js
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;beforeCreate&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Vue component beforeCreate&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="nf"&gt;created&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Vue component created&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="nf"&gt;mounted&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Vue component mounted&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  React
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;MyComponent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;React component mounted&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;React component will unmount&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[]);&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Component Content&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Event Handling
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Definition and Characteristics
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Vue.js
&lt;/h4&gt;

&lt;p&gt;Uses directives like &lt;code&gt;@click&lt;/code&gt; and &lt;code&gt;@input&lt;/code&gt;. These directives make it easy to add event listeners. Vue.js directives simplify event handling.&lt;/p&gt;

&lt;h4&gt;
  
  
  React
&lt;/h4&gt;

&lt;p&gt;Event listeners are written in camelCase and passed directly to JSX. Event listeners are specified as JSX attributes, integrating UI construction with event handling.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Samples
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Vue.js
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="na"&gt;click=&lt;/span&gt;&lt;span class="s"&gt;"handleClick"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Click Me&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  React
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleClick&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Click Me&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  6. Conditional Rendering
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Definition and Characteristics
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Vue.js
&lt;/h4&gt;

&lt;p&gt;Uses &lt;code&gt;v-if&lt;/code&gt; and &lt;code&gt;v-else&lt;/code&gt; directives. These directives control UI rendering based on conditions. Vue.js's conditional rendering makes UI control easier.&lt;/p&gt;

&lt;h4&gt;
  
  
  React
&lt;/h4&gt;

&lt;p&gt;Conditions are written directly in JSX. Conditions are evaluated as JSX expressions, allowing more flexible UI rendering control.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Samples
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Vue.js
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;v-if=&lt;/span&gt;&lt;span class="s"&gt;"isLoggedIn"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Welcome!&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;v-else&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Please log in.&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  React
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;isLoggedIn&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Welcome!&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Please log in.&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  7. List Rendering
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Definition and Characteristics
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Vue.js
&lt;/h4&gt;

&lt;p&gt;Uses the &lt;code&gt;v-for&lt;/code&gt; directive. The directive renders UI for each array element. Vue.js's list rendering makes it easy to render UI for array elements.&lt;/p&gt;

&lt;h4&gt;
  
  
  React
&lt;/h4&gt;

&lt;p&gt;Uses the &lt;code&gt;map&lt;/code&gt; method. The &lt;code&gt;map&lt;/code&gt; method renders UI for each array element. React's list rendering is a powerful tool for rendering UI from array elements.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Samples
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Vue.js
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;v-for=&lt;/span&gt;&lt;span class="s"&gt;"item in items"&lt;/span&gt; &lt;span class="na"&gt;:key=&lt;/span&gt;&lt;span class="s"&gt;"item.id"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;{{ item.name }}&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  React
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;li&lt;/span&gt; &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;li&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  8. Form Binding
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Definition and Characteristics
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Vue.js
&lt;/h4&gt;

&lt;p&gt;Uses &lt;code&gt;v-model&lt;/code&gt; for easy two-way binding. User input is automatically reflected in the data. Vue.js's form binding makes user interface development easier by automatically reflecting form input in data.&lt;/p&gt;

&lt;h4&gt;
  
  
  React
&lt;/h4&gt;

&lt;p&gt;Explicitly manages values through &lt;code&gt;onChange&lt;/code&gt; events. User input is explicitly reflected in the data. React's form binding allows finer control by explicitly reflecting form input in data.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Samples
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Vue.js
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;v-model=&lt;/span&gt;&lt;span class="s"&gt;"name"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  React
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;input&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;onChange&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  9. Conclusion
&lt;/h2&gt;

&lt;p&gt;React and Vue.js each have their own unique characteristics. Use this comparison as a reference to choose the framework that best suits your project needs.&lt;/p&gt;

</description>
      <category>react</category>
      <category>vue</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Git Commands for Breaking Down Large Code Changes into Smaller PRs</title>
      <dc:creator>OE Haruki</dc:creator>
      <pubDate>Tue, 11 Feb 2025 10:40:34 +0000</pubDate>
      <link>https://dev.to/oeharuki/git-commands-for-breaking-down-large-code-changes-into-smaller-prs-2n84</link>
      <guid>https://dev.to/oeharuki/git-commands-for-breaking-down-large-code-changes-into-smaller-prs-2n84</guid>
      <description>&lt;p&gt;Even if you've already committed many changes to a single branch, it's possible to break them down into smaller, more manageable PRs.&lt;br&gt;
This article explains the detailed process.&lt;/p&gt;
&lt;h2&gt;
  
  
  1. Check Current Status
&lt;/h2&gt;

&lt;p&gt;First, review what commits exist in your current branch.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git log &lt;span class="nt"&gt;--oneline&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If all changes are in the latest commit, proceed to the next step.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Reset Latest Commit
&lt;/h2&gt;

&lt;p&gt;Reset the latest commit to move changes back to the staging area. Using the &lt;code&gt;--soft&lt;/code&gt; option preserves the working directory changes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git reset &lt;span class="nt"&gt;--soft&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;target branch &lt;span class="k"&gt;for &lt;/span&gt;eventual merge]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;--soft&lt;/code&gt;: Undoes the commit and returns changes to the index.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. Stage Changes in Smaller Units
&lt;/h2&gt;

&lt;p&gt;Use &lt;code&gt;git add -p&lt;/code&gt; to stage changes in smaller chunks.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add &lt;span class="nt"&gt;-p&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Prompt commands:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;y&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Stage this change&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;n&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Skip this change&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;q&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Skip all remaining changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;s&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Split current change into smaller chunks&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  4. Create Small Commits
&lt;/h2&gt;

&lt;p&gt;Commit the staged changes.&lt;br&gt;
Repeat this process to break down large changes into smaller commits.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"feat: add feature xxx"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Update Remote Repository
&lt;/h2&gt;

&lt;p&gt;If the branch has already been pushed to the remote repository, you'll need to overwrite the history.&lt;br&gt;
Use the &lt;code&gt;--force-with-lease&lt;/code&gt; option to safely overwrite.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git push &lt;span class="nt"&gt;--force-with-lease&lt;/span&gt; origin feature/large-update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;--force-with-lease&lt;/code&gt;: Checks remote state and forces push only if no one else has made changes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  6. Create PR
&lt;/h2&gt;

&lt;p&gt;After reflecting the split branch to the remote repository, create a PR.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Repeat Process on New Branch
&lt;/h2&gt;

&lt;p&gt;After completing the first PR, create a new branch and repeat the same process.&lt;br&gt;
Here's the workflow:&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;a. Create New Branch&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Switch to a new branch from the current state.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout &lt;span class="nt"&gt;-b&lt;/span&gt; feature/next-small-pr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;b. Stage Remaining Changes&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Use &lt;code&gt;git add -p&lt;/code&gt; again to stage and split the remaining changes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add &lt;span class="nt"&gt;-p&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;c. Commit and Push&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Commit in appropriate units and push to remote as a new branch.&lt;br&gt;
Since we haven't reset this branch, a normal &lt;code&gt;git push&lt;/code&gt; is fine.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Refactor module Y"&lt;/span&gt;
git push origin feature/next-small-pr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;d. Create Next PR&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Create a PR from the new branch and request review.&lt;br&gt;
Repeat this process as needed to organize the large code change into several smaller PRs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary Table of Overall Flow
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;Example Command&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Check Current Status&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;git log --oneline&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Review current commit history&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Reset&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;git reset --soft [target branch]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Undo all commits on branch and return changes to staging area&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Stage Changes in Parts&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;git add -p&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Interactively select and split changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Commit&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;git commit -m "..."&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Commit selected changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Update Remote&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;git push --force-with-lease origin feature/large-update&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Overwrite history and update remote&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Create New Branch&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;git checkout -b feature/next-small-pr&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Start work on new branch for next changes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Important Notes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Be Careful with Force Push&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
While &lt;code&gt;--force-with-lease&lt;/code&gt; reduces the risk of overwriting others' changes, always ensure you're working with the latest state.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Don't Split Too Small&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
It's important to split into meaningful units. Use "one logical unit" as your guideline.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With these steps, you can safely and efficiently split large changes into smaller PRs, even after committing many changes to a single branch!&lt;br&gt;
Give it a try!&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>terminal</category>
      <category>cli</category>
    </item>
    <item>
      <title>A Guide to Alt Attributes for Frontend Developers</title>
      <dc:creator>OE Haruki</dc:creator>
      <pubDate>Tue, 11 Feb 2025 10:37:26 +0000</pubDate>
      <link>https://dev.to/oeharuki/a-guide-to-alt-attributes-for-frontend-developers-4238</link>
      <guid>https://dev.to/oeharuki/a-guide-to-alt-attributes-for-frontend-developers-4238</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;The alt attribute is a crucial HTML attribute that provides textual descriptions of images, translating visual content into verbal form.&lt;br&gt;
In the context of web accessibility, it plays a vital role particularly in the following scenarios:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When users with visual impairments use screen readers&lt;/li&gt;
&lt;li&gt;When images fail to load due to network issues&lt;/li&gt;
&lt;li&gt;When users have disabled image display&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In WCAG 2.2, proper use of alt attributes is specified under Success Criterion 1.1.1 "Non-text Content" (Level A).&lt;br&gt;
This criterion requires that all non-text content, except for decorative elements, must have text alternatives that serve the equivalent purpose.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.w3.org/WAI/WCAG22/Understanding/non-text-content" rel="noopener noreferrer"&gt;https://www.w3.org/WAI/WCAG22/Understanding/non-text-content&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Basic Specifications of Alt Attributes
&lt;/h2&gt;

&lt;p&gt;According to the HTML Living Standard, the alt attribute is required for img elements.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://html.spec.whatwg.org/multipage/images.html#alt" rel="noopener noreferrer"&gt;https://html.spec.whatwg.org/multipage/images.html#alt&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The basic syntax is as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"path/to/image.jpg"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"Description of the image"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are primarily two patterns for using alt attributes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Providing Alternative Text&lt;/strong&gt;&lt;br&gt;
When an image conveys information, set appropriate alternative text describing its content.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Using Empty Alt Attributes&lt;/strong&gt;&lt;br&gt;
For decorative images, set an empty value like &lt;code&gt;alt=""&lt;/code&gt;.&lt;br&gt;
This causes screen readers to ignore the image's presence.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Key Points for Effective Alt Text
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Keep Descriptions Concise and Accurate
&lt;/h3&gt;

&lt;p&gt;Alternative text should focus on the essential information the image aims to convey.&lt;br&gt;
For product images, for example, it's important to concisely describe the product name and key features.&lt;/p&gt;

&lt;p&gt;❌ Poor example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"coffee.jpg"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"A black ceramic mug with a handle placed on a white background, with steam rising from it"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ Good example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"coffee.jpg"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"Hot coffee in a black mug"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Context-Aware Descriptions
&lt;/h3&gt;

&lt;p&gt;The appropriate alternative text for the same image may vary depending on its location and purpose.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- When used in navigation --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"home.svg"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"Home"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="c"&gt;&amp;lt;!-- When indicating current location --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"home.svg"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"Current page: Home"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Consider Appropriate Length
&lt;/h3&gt;

&lt;p&gt;While there's no strict character limit for alt attributes, overly long descriptions can impact usability when read by screen readers.&lt;br&gt;
WebAIM and MDN Web Docs emphasize the importance of being "concise" in alt attributes.&lt;br&gt;
&lt;a href="https://webaim.org/techniques/alttext/" rel="noopener noreferrer"&gt;https://webaim.org/techniques/alttext/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#usage_notes" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#usage_notes&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For complex diagrams or charts, consider using &lt;code&gt;aria-describedby&lt;/code&gt; to provide detailed descriptions when necessary.&lt;br&gt;
(More on &lt;code&gt;aria-describedby&lt;/code&gt; later.)&lt;/p&gt;
&lt;h3&gt;
  
  
  Other Important Considerations
&lt;/h3&gt;

&lt;p&gt;When writing alt attributes, keep these points in mind:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Avoid redundant prefixes like "image:" or "photo:"&lt;/li&gt;
&lt;li&gt;Don't use file names as alt text&lt;/li&gt;
&lt;li&gt;Use empty alt attributes (&lt;code&gt;alt=""&lt;/code&gt;) for decorative images&lt;/li&gt;
&lt;li&gt;For images functioning as links or buttons, describe the action that occurs when clicked&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Practical Examples by Use Case
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Decorative Images
&lt;/h3&gt;

&lt;p&gt;For images used purely for decoration (dividers, background images, decorative icons), set an empty alt attribute.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"decoration.png"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This prevents screen readers from announcing unnecessary information by ignoring the image's presence.&lt;/p&gt;

&lt;h3&gt;
  
  
  Images as Navigation Elements
&lt;/h3&gt;

&lt;p&gt;For images functioning as buttons or links, clearly describe what happens upon interaction.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"menu.svg"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"Open menu"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"twitter.svg"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"Share on Twitter"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Infographics and Charts
&lt;/h3&gt;

&lt;p&gt;For data visualizations, concisely explain the main information or trends.&lt;br&gt;
Consider using &lt;code&gt;aria-describedby&lt;/code&gt; to provide detailed data when necessary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"graph.png"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"Sales increased 20% in 2023 compared to previous year"&lt;/span&gt; &lt;span class="na"&gt;aria-describedby=&lt;/span&gt;&lt;span class="s"&gt;"graph-details"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"graph-details"&lt;/span&gt; &lt;span class="na"&gt;hidden&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    Q1: $1M
    Q2: $1.5M
    Q3: $2M
    Q4: $2.5M
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Product Images and Logos
&lt;/h3&gt;

&lt;p&gt;For e-commerce product images, include the product name and important visual characteristics concisely.&lt;/p&gt;

&lt;p&gt;For company or brand logos, typically use the brand name as alternative text.&lt;br&gt;
However, when functioning as a link, additional context might be needed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- Product image example --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"product.jpg"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"Leather handbag - Brown with gold hardware"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="c"&gt;&amp;lt;!-- Logo image example --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"/"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"logo.png"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"Company Name - Return to homepage"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Alternative Approaches
&lt;/h2&gt;

&lt;p&gt;When alt attributes alone aren't sufficient, consider these alternatives:&lt;/p&gt;

&lt;h3&gt;
  
  
  aria-label / aria-labelledby
&lt;/h3&gt;

&lt;p&gt;Attributes that provide direct labels for elements.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;aria-label=&lt;/span&gt;&lt;span class="s"&gt;"Open menu"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"menu.svg"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  figure and figcaption Elements
&lt;/h3&gt;

&lt;p&gt;Semantically group images with their descriptions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;figure&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"graph.png"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"Quarterly sales graph for 2023"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;figcaption&amp;gt;&lt;/span&gt;
        Sales grew steadily from Q1, achieving 150% year-over-year growth in Q4.
    &lt;span class="nt"&gt;&amp;lt;/figcaption&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/figure&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Validation and Testing
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Screen Reader Testing
&lt;/h3&gt;

&lt;p&gt;Check the following points with major screen readers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Alternative text is read properly&lt;/li&gt;
&lt;li&gt;Decorative images are appropriately skipped&lt;/li&gt;
&lt;li&gt;Reading order is logical&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Recommended screen readers include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;macOS: VoiceOver&lt;/li&gt;
&lt;li&gt;Windows: NVDA, Narrator&lt;/li&gt;
&lt;li&gt;Mobile: VoiceOver (iOS), TalkBack (Android)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Automated Check Tools
&lt;/h3&gt;

&lt;p&gt;Use these tools to detect basic issues:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;axe DevTools&lt;/li&gt;
&lt;li&gt;WAVE&lt;/li&gt;
&lt;li&gt;Lighthouse&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Key points for proper alt attribute implementation:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Basic Principles&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Provide appropriate alternative text based on image purpose and context&lt;/li&gt;
&lt;li&gt;Use empty alt attributes for decorative images&lt;/li&gt;
&lt;li&gt;Keep descriptions concise and accurate&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Implementation Best Practices&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Avoid redundant descriptions&lt;/li&gt;
&lt;li&gt;Utilize appropriate alternatives when needed&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Quality Control&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Regular testing with screen readers&lt;/li&gt;
&lt;li&gt;Use automated checking tools&lt;/li&gt;
&lt;li&gt;Code review verification&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>a11y</category>
      <category>html</category>
    </item>
    <item>
      <title>Understanding the 4 Principles of WCAG (Perceivable, Operable, Understandable, Robust)</title>
      <dc:creator>OE Haruki</dc:creator>
      <pubDate>Tue, 11 Feb 2025 10:30:18 +0000</pubDate>
      <link>https://dev.to/oeharuki/understanding-the-4-principles-of-wcag-perceivable-operable-understandable-robust-2c55</link>
      <guid>https://dev.to/oeharuki/understanding-the-4-principles-of-wcag-perceivable-operable-understandable-robust-2c55</guid>
      <description>&lt;p&gt;WCAG (Web Content Accessibility Guidelines) is an international standard for ensuring web accessibility.&lt;/p&gt;

&lt;p&gt;Before diving deep into WCAG's principles, it's helpful to understand its overall structure. &lt;br&gt;
For a comprehensive overview of WCAG's structure, please refer to this article:&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/oeharuki" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2846763%2Fe57e4906-df0b-48d0-bc7b-fa15213369d8.jpg" alt="oeharuki"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/oeharuki/understanding-wcag-structure-principles-guidelines-success-criteria-and-supporting-documents-1fc" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Understanding WCAG: Structure, Principles, Guidelines, Success Criteria, and Supporting Documents&lt;/h2&gt;
      &lt;h3&gt;OE Haruki ・ Feb 11&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#a11y&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#ui&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#html&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#css&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


&lt;p&gt;Now, let's explore the four principles (Perceivable, Operable, Understandable, and Robust) that form the foundation of WCAG.&lt;/p&gt;

&lt;h2&gt;
  
  
  Perceivable
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Information and user interface components must be presentable to users in ways they can perceive.&lt;sup id="fnref1"&gt;1&lt;/sup&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The concept is straightforward.&lt;br&gt;
This principle requires that web content and interfaces must be perceivable to users.&lt;/p&gt;

&lt;p&gt;This means content shouldn't be in a state where it's "neither visible, nor audible, nor tactilely perceivable."&lt;/p&gt;

&lt;p&gt;While we won't delve into the specific guidelines under this principle, here are some key requirements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Enable screen reader users to understand information through audio&lt;/li&gt;
&lt;li&gt;Provide captions for video content so deaf users can understand it&lt;/li&gt;
&lt;li&gt;Ensure form requirements are indicated by both color and text for color-blind users&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If content can't be perceived visually, make it perceivable through audio.&lt;br&gt;
If it can't be perceived through audio, make it perceivable visually.&lt;br&gt;
If it can't be perceived through color vision, make it perceivable through other visual means.&lt;/p&gt;

&lt;p&gt;Providing information through only one sensory channel makes it "imperceivable" to those with impairments in that specific sense.&lt;br&gt;
Therefore, offering information through multiple sensory channels significantly expands the range of "perceivability."&lt;/p&gt;

&lt;p&gt;However, implementing accessibility involves complex challenges.&lt;br&gt;
For example, even if visual information is made available through audio, it remains "imperceivable" to deafblind users who have both visual and hearing impairments.&lt;/p&gt;

&lt;p&gt;This doesn't mean such accommodations are meaningless.&lt;br&gt;
Many deafblind users access the web using refreshable braille displays.&lt;br&gt;
For instance, adding alt attributes to images not only conveys information audibly through screen readers but also enables tactile information transmission through braille displays.&lt;/p&gt;

&lt;p&gt;To accommodate diverse disabilities, it's crucial to combine multiple sensory information delivery methods.&lt;br&gt;
Each accommodation may benefit users with different disabilities.&lt;br&gt;
Improving accessibility is achieved through such multi-layered approaches.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.w3.org/WAI/WCAG22/Understanding/perceivable" rel="noopener noreferrer"&gt;https://www.w3.org/WAI/WCAG22/Understanding/perceivable&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Operable
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;User interface components and navigation must be operable.&lt;sup id="fnref1"&gt;1&lt;/sup&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This principle requires that user interfaces and navigation must be operable.&lt;/p&gt;

&lt;p&gt;While many people use a mouse to browse websites, mouse usage primarily assumes a visual interface.&lt;br&gt;
However, some visually impaired users find mouse operation difficult and rely solely on keyboard navigation.&lt;br&gt;
The "Operable" principle demands that websites be designed to accommodate various input methods to meet diverse needs.&lt;/p&gt;

&lt;p&gt;Beyond keyboards, we must consider users who rely on various input devices such as touchscreens, voice recognition software, and braille displays.&lt;/p&gt;

&lt;p&gt;This principle isn't just for people with disabilities; it also applies to temporary situations where specific devices are unavailable (e.g., when a touchpad malfunctions).&lt;br&gt;
In such cases, ensuring keyboard-only operation becomes crucial.&lt;/p&gt;

&lt;p&gt;Furthermore, the Operable principle emphasizes preventing seizures and allowing sufficient time to understand and operate content.&lt;br&gt;
Rapid light flashes may trigger seizures in users with conditions like epilepsy.&lt;br&gt;
Since information processing speeds vary among users, adequate time must be provided.&lt;br&gt;
(For example, implementing speed control features for slideshows.)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.w3.org/WAI/WCAG22/Understanding/operable" rel="noopener noreferrer"&gt;https://www.w3.org/WAI/WCAG22/Understanding/operable&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Understandable
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Information and the operation of user interface must be understandable.&lt;sup id="fnref1"&gt;1&lt;/sup&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This principle requires that web content and interfaces be clear and usable for users with various abilities and experiences.&lt;/p&gt;

&lt;p&gt;Let's consider the hamburger menu button as an example.&lt;br&gt;
This button typically consists of three horizontal lines and expands a menu when clicked.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Hamburger_button" rel="noopener noreferrer"&gt;https://en.wikipedia.org/wiki/Hamburger_button&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;While many readers of this article, such as engineers and designers familiar with web interfaces, might predict that "clicking will expand a menu," this isn't universally intuitive.&lt;/p&gt;

&lt;p&gt;The following users might find it &lt;strong&gt;difficult to understand the meaning and function of this interface&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Elderly people&lt;/li&gt;
&lt;li&gt;Those unfamiliar with web technology&lt;/li&gt;
&lt;li&gt;People with cognitive or learning disabilities&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To avoid such situations, approaches like using alternative, more predictable user interface operations are necessary.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Design user interface operations to be predictable&lt;/li&gt;
&lt;li&gt;Provide clear and understandable labels for buttons and links&lt;/li&gt;
&lt;li&gt;Maintain consistent design and navigation throughout the site&lt;/li&gt;
&lt;li&gt;Clearly identify errors and provide correction methods when they occur in input forms&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These measures help various users understand and properly operate web content.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.w3.org/WAI/WCAG22/Understanding/understandable" rel="noopener noreferrer"&gt;https://www.w3.org/WAI/WCAG22/Understanding/understandable&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Robust
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Content must be robust enough to be interpreted reliably by a wide variety of user agents, including assistive technologies.&lt;sup id="fnref1"&gt;1&lt;/sup&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This principle requires that content be reliably interpretable by various user agents and assistive technologies.&lt;/p&gt;

&lt;p&gt;As we transition from PCs to smartphones, new devices may emerge in the future.&lt;br&gt;
Input devices continue to evolve, and more convenient alternatives to current keyboards and mice may be developed.&lt;/p&gt;

&lt;p&gt;Browser market share may also shift. While Google Chrome currently dominates, emerging browsers might gain prominence in the future.&lt;/p&gt;

&lt;p&gt;Technology and user agents continue to evolve. Therefore, content itself needs to be "accessible" to accommodate these changes.&lt;br&gt;
Here, "accessible" means &lt;strong&gt;"being reliably interpretable by evolving technologies and user agents."&lt;/strong&gt;&lt;br&gt;
It's important to ensure consistent behavior and content across different browsers and devices.&lt;/p&gt;

&lt;p&gt;To ensure "robustness," consider the following approaches:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Writing structured HTML&lt;/li&gt;
&lt;li&gt;Conducting multi-browser and cross-platform testing&lt;/li&gt;
&lt;li&gt;Improving dynamic content accessibility through proper WAI-ARIA implementation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://www.w3.org/WAI/WCAG22/Understanding/robust" rel="noopener noreferrer"&gt;https://www.w3.org/WAI/WCAG22/Understanding/robust&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;The four WCAG principles (Perceivable, Operable, Understandable, and Robust) are fundamental guidelines for web accessibility.&lt;br&gt;
These principles form the highest-level concepts in WCAG and serve as the foundation for ensuring web content accessibility.&lt;/p&gt;

&lt;p&gt;A deep understanding of these principles enables a more conceptual understanding of the guidelines and success criteria based on them.&lt;br&gt;
While WCAG receives major updates periodically, these principles remain more stable compared to individual success criteria.&lt;br&gt;
These principles function as core concepts of web accessibility regardless of technological or situational changes.&lt;br&gt;
Therefore, they can serve as long-term guidelines for teams and organizations.&lt;/p&gt;




&lt;ol&gt;

&lt;li id="fn1"&gt;
&lt;p&gt;"Web Content Accessibility Guidelines (WCAG) 2.2", W3C, December 12, 2024, &lt;a href="https://www.w3.org/TR/WCAG22/" rel="noopener noreferrer"&gt;https://www.w3.org/TR/WCAG22/&lt;/a&gt; (accessed 2024-12-27) ↩&lt;/p&gt;
&lt;/li&gt;

&lt;/ol&gt;

</description>
      <category>a11y</category>
      <category>wcag</category>
    </item>
    <item>
      <title>Understanding WCAG: Structure, Principles, Guidelines, and Success Criteria</title>
      <dc:creator>OE Haruki</dc:creator>
      <pubDate>Tue, 11 Feb 2025 10:13:12 +0000</pubDate>
      <link>https://dev.to/oeharuki/understanding-wcag-structure-principles-guidelines-success-criteria-and-supporting-documents-1fc</link>
      <guid>https://dev.to/oeharuki/understanding-wcag-structure-principles-guidelines-success-criteria-and-supporting-documents-1fc</guid>
      <description>&lt;p&gt;WCAG (Web Content Accessibility Guidelines) is an essential guideline when discussing web accessibility.&lt;/p&gt;

&lt;p&gt;While it might seem overwhelming at first, all the content is actually consolidated into a single page.&lt;/p&gt;

&lt;p&gt;If you find accessibility challenging, don't worry. While this single page is content-rich, its beauty lies in the fact that you can easily check accessibility basics without constantly referring to multiple pages.&lt;/p&gt;

&lt;p&gt;As of December 28, 2024, WCAG 2.2 is the latest version. You can access it here:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.w3.org/TR/WCAG22/" rel="noopener noreferrer"&gt;https://www.w3.org/TR/WCAG22/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This article explains WCAG's overview and structure, detailing the roles of its &lt;strong&gt;Principles, Guidelines, Success Criteria, and Supporting Documents&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  WCAG Overview and Purpose
&lt;/h2&gt;

&lt;p&gt;WCAG (Web Content Accessibility Guidelines) is an international accessibility standard developed by WAI (Web Accessibility Initiative), a branch of W3C (World Wide Web Consortium), the international standards organization for the internet.&lt;/p&gt;

&lt;p&gt;The primary goal of these guidelines is to &lt;strong&gt;ensure equal access and usability of web content for all people, regardless of their disabilities, limitations, or usage environment&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;WCAG specifically aims to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Address diverse disabilities including visual (blindness, low vision), auditory (deaf, hard of hearing), motor, speech, cognitive/learning disabilities, and photosensitive seizures&lt;/li&gt;
&lt;li&gt;Consider broader user groups including elderly people and those with temporary disabilities&lt;/li&gt;
&lt;li&gt;Ensure accessibility for people using the web in various environments and situations&lt;/li&gt;
&lt;li&gt;Improve overall usability&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;WCAG is an international standard created through global collaboration, designed to be applicable across current and future web technologies. It serves as a comprehensive guide for creating &lt;strong&gt;"universally usable"&lt;/strong&gt; web content.&lt;/p&gt;

&lt;h2&gt;
  
  
  WCAG's Hierarchical Structure and How to Read It
&lt;/h2&gt;

&lt;p&gt;WCAG is organized in a three-tier hierarchical structure.&lt;br&gt;
Understanding this structure makes WCAG easier to comprehend.&lt;/p&gt;
&lt;h3&gt;
  
  
  Hierarchical Structure
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Level&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Principles&lt;/td&gt;
&lt;td&gt;Top-level concepts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Guidelines&lt;/td&gt;
&lt;td&gt;Concrete objectives under principles&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Success Criteria&lt;/td&gt;
&lt;td&gt;Detailed requirements under guidelines&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Each top-level "Principle" contains multiple "Guidelines," and each Guideline includes multiple "Success Criteria."&lt;/p&gt;
&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Principle 1&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Guideline 1.1&lt;/li&gt;
&lt;li&gt;Success Criterion 1.1.1&lt;/li&gt;
&lt;li&gt;Guideline 1.2&lt;/li&gt;
&lt;li&gt;Success Criterion 1.2.1&lt;/li&gt;
&lt;li&gt;Guideline 1.3&lt;/li&gt;
&lt;li&gt;Success Criterion 1.3.1&lt;/li&gt;
&lt;li&gt;Success Criterion 1.3.2&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Principle 2&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Guideline 2.1&lt;/li&gt;
&lt;li&gt;Success Criterion 2.1.1

&lt;ul&gt;
&lt;li&gt;...etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  How to Read the Table of Contents
&lt;/h3&gt;

&lt;p&gt;WCAG document numbers follow the format &lt;strong&gt;"Principle.Guideline.Success Criterion"&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For example, looking at this WCAG document:&lt;br&gt;
&lt;a href="https://www.w3.org/TR/WCAG22/#audio-description-or-media-alternative-prerecorded" rel="noopener noreferrer"&gt;https://www.w3.org/TR/WCAG22/#audio-description-or-media-alternative-prerecorded&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The reference number &lt;strong&gt;1.2.3&lt;/strong&gt; indicates:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Under the &lt;strong&gt;1&lt;/strong&gt;st principle (Perceivable)&lt;/li&gt;
&lt;li&gt;Under the &lt;strong&gt;2&lt;/strong&gt;nd guideline (Time-based Media)&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;3&lt;/strong&gt;rd success criterion (Audio Description or Media Alternative (Prerecorded))&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Understanding this structure helps locate items efficiently within the WCAG documentation.&lt;/p&gt;
&lt;h2&gt;
  
  
  Principles
&lt;/h2&gt;

&lt;p&gt;WCAG is built on four core principles.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Principle&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;P&lt;/strong&gt;erceivable&lt;/td&gt;
&lt;td&gt;Information and UI components must be presentable to users in ways they can perceive.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;O&lt;/strong&gt;perable&lt;/td&gt;
&lt;td&gt;User interface components and navigation must be operable.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;U&lt;/strong&gt;nderstandable&lt;/td&gt;
&lt;td&gt;Information and operation must be understandable.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;R&lt;/strong&gt;obust&lt;/td&gt;
&lt;td&gt;Content must be robust enough to work with current and future technologies.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These principles are sometimes referred to as the &lt;strong&gt;POUR principles&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you would like to learn more about the principles, please also read the following article.&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/oeharuki" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2846763%2Fe57e4906-df0b-48d0-bc7b-fa15213369d8.jpg" alt="oeharuki"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/oeharuki/understanding-the-4-principles-of-wcag-perceivable-operable-understandable-robust-2c55" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Understanding the 4 Principles of WCAG (Perceivable, Operable, Understandable, Robust)&lt;/h2&gt;
      &lt;h3&gt;OE Haruki ・ Feb 11&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#a11y&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#wcag&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  Guidelines
&lt;/h2&gt;

&lt;p&gt;Under each principle, guidelines define goals for improving accessibility. WCAG 2.2 contains 13 guidelines.&lt;/p&gt;

&lt;p&gt;Guidelines provide &lt;strong&gt;context and purpose&lt;/strong&gt; for understanding specific success criteria.&lt;br&gt;
While principles represent abstract concepts, guidelines provide general directions for achieving these principles.&lt;br&gt;
(The specific implementation details are covered in the success criteria.)&lt;/p&gt;

&lt;p&gt;For example, under the "Perceivable" principle, these guidelines are provided:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Text Alternatives:&lt;/strong&gt; Provide text alternatives for non-text content.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Time-based Media:&lt;/strong&gt; Provide alternatives for time-based media.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Adaptable:&lt;/strong&gt; Create content that can be presented in different ways without losing structure.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Distinguishable:&lt;/strong&gt; Make it easier for users to see and hear content.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Success Criteria
&lt;/h2&gt;

&lt;p&gt;While guidelines provide context and purpose, success criteria are &lt;strong&gt;specific, testable requirements&lt;/strong&gt;.&lt;br&gt;
They serve as the basis for determining WCAG conformance.&lt;/p&gt;
&lt;h3&gt;
  
  
  Three Conformance Levels
&lt;/h3&gt;

&lt;p&gt;Success criteria are categorized into three conformance levels,&lt;br&gt;
indicating different degrees of web content accessibility.&lt;/p&gt;
&lt;h4&gt;
  
  
  Level A
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Meets minimum standards&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Must satisfy all Level A success criteria&lt;/li&gt;
&lt;li&gt;Meets basic requirements but may still present barriers for some users&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  Level AA
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Target level for most organizations and government agencies&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Must satisfy all Level A and AA success criteria&lt;/li&gt;
&lt;li&gt;Makes content accessible to most users&lt;/li&gt;
&lt;li&gt;Widely adopted as legal requirements and industry standards&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  Level AAA
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Represents the highest standard&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Must satisfy all Level A, AA, and AAA success criteria&lt;/li&gt;
&lt;li&gt;Very challenging to achieve and may not be possible in all situations&lt;/li&gt;
&lt;li&gt;Not recommended as a general policy for entire sites&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Implementation Example
&lt;/h3&gt;

&lt;p&gt;Success criteria provide practical standards for web development.&lt;br&gt;
Here's an example:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Success Criterion 1.1.1 Non-text Content&lt;/strong&gt;&lt;br&gt;
All non-text content that is presented to the user has a text alternative that serves the equivalent purpose.&lt;sup id="fnref1"&gt;1&lt;/sup&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To meet this criterion, implement something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"logo.png"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"W3C"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This implementation satisfies the success criterion by providing alt text (text alternative) for the image (non-text content).&lt;/p&gt;

&lt;h2&gt;
  
  
  Supporting Documents
&lt;/h2&gt;

&lt;p&gt;Supporting documents exist below success criteria to provide detailed explanations and implementation guidance.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.w3.org/WAI/WCAG22/Understanding/" rel="noopener noreferrer"&gt;https://www.w3.org/WAI/WCAG22/Understanding/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For example, the following page explains the &lt;strong&gt;intent, benefits, examples, and techniques&lt;/strong&gt; for "Success Criterion 1.1.1 Non-text Content":&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.w3.org/WAI/WCAG22/Understanding/non-text-content" rel="noopener noreferrer"&gt;https://www.w3.org/WAI/WCAG22/Understanding/non-text-content&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Difference Between Supporting Documents and Success Criteria
&lt;/h3&gt;

&lt;p&gt;Success criteria define "requirements to be met" for ensuring accessibility.&lt;br&gt;
These are normative parts used to evaluate WCAG compliance.&lt;br&gt;
Supporting documents provide "supplementary information" to help understand and implement the criteria.&lt;br&gt;
These are non-normative materials used as references.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Success Criteria&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Normative&lt;/li&gt;
&lt;li&gt;Provides WCAG conformance criteria&lt;/li&gt;
&lt;li&gt;Mandatory requirements&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Supporting Documents&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Non-normative&lt;/li&gt;
&lt;li&gt;Supports understanding and implementation&lt;/li&gt;
&lt;li&gt;Explanations, examples, reference information (including failures)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  WCAG Versions and Evolution
&lt;/h2&gt;

&lt;p&gt;WCAG has evolved with technological advances while maintaining its core purpose of "making web content accessible to all."&lt;/p&gt;

&lt;p&gt;WCAG 2.1 and 2.2 are backward compatible with previous versions.&lt;br&gt;
Conforming to WCAG 2.2 automatically means conformance to WCAG 2.1 and 2.0.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Version&lt;/th&gt;
&lt;th&gt;Year&lt;/th&gt;
&lt;th&gt;Key Features&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1.0&lt;/td&gt;
&lt;td&gt;1999&lt;/td&gt;
&lt;td&gt;Initial version. HTML/CSS focused with 14 guidelines.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2.0&lt;/td&gt;
&lt;td&gt;2008&lt;/td&gt;
&lt;td&gt;Technology-agnostic approach with 4 principles, 12 guidelines, 61 success criteria.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2.1&lt;/td&gt;
&lt;td&gt;2018&lt;/td&gt;
&lt;td&gt;Added 17 success criteria focusing on mobile devices, low vision, and cognitive disabilities.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2.2&lt;/td&gt;
&lt;td&gt;2023&lt;/td&gt;
&lt;td&gt;Added 9 success criteria including authentication methods and focus indicators.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3.0&lt;/td&gt;
&lt;td&gt;Draft&lt;/td&gt;
&lt;td&gt;Considering changes to evaluation metrics and conformance levels.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;ol&gt;

&lt;li id="fn1"&gt;
&lt;p&gt;"Web Content Accessibility Guidelines (WCAG) 2.2", W3C, October 5, 2023, &lt;a href="https://www.w3.org/TR/WCAG22/#non-text-content" rel="noopener noreferrer"&gt;https://www.w3.org/TR/WCAG22/#non-text-content&lt;/a&gt; (accessed 2024-12-27) ↩&lt;/p&gt;
&lt;/li&gt;

&lt;/ol&gt;

</description>
      <category>a11y</category>
      <category>ui</category>
      <category>html</category>
      <category>css</category>
    </item>
  </channel>
</rss>
