<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>CSS Archives - Sourced Code</title>
	<atom:link href="https://sourcedcode.com/blog/category/css/feed" rel="self" type="application/rss+xml" />
	<link>https://sourcedcode.com</link>
	<description>AEM Blog Made Just for You.</description>
	<lastBuildDate>Sat, 16 Dec 2023 20:30:24 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.4.8</generator>

<image>
	<url>https://sourcedcode.com/wp-content/uploads/2019/09/cropped-favicon-32x32.png</url>
	<title>CSS Archives - Sourced Code</title>
	<link>https://sourcedcode.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Chrome Reset with the Outline CSS Property</title>
		<link>https://sourcedcode.com/blog/css/chrome-reset-with-the-outline-css-property</link>
					<comments>https://sourcedcode.com/blog/css/chrome-reset-with-the-outline-css-property#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Fri, 15 Dec 2023 14:22:06 +0000</pubDate>
				<category><![CDATA[CSS]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=6386</guid>

					<description><![CDATA[<p>Let&#8217;s delve into an approach to reset the Chrome outline CSS property. Our focus will be on two key declarations: outline-color: auto; and outline-color: -webkit-focus-ring-color;. Quick Links Understanding the Accessibility-Driven Outline CSS Property Resetting Chrome for Accessibility with outline-color Resetting Chrome with Browser-Specific Accessibility: outline-color: -webkit-focus-ring-color; Code Example, Together Conclusion 1. Understanding the Accessibility-Driven Outline [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/css/chrome-reset-with-the-outline-css-property">Chrome Reset with the Outline CSS Property</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<section>
<p>Let&#8217;s delve into an approach to reset the Chrome <span class="code-highlight-secondary">outline</span> CSS property. Our focus will be on two key declarations: <span class="code-highlight-secondary">outline-color: auto;</span> and <span class="code-highlight-secondary">outline-color: -webkit-focus-ring-color;</span>.</p>
</section>
<div class="mention-block">
    <strong>Quick Links</strong></p>
<ol>
<li><a href="#section-1">Understanding the Accessibility-Driven Outline CSS Property</a></li>
<li><a href="#section-2">Resetting Chrome for Accessibility with outline-color</a></li>
<li><a href="#section-3">Resetting Chrome with Browser-Specific Accessibility: outline-color: -webkit-focus-ring-color;</a></li>
<li><a href="#section-4">Code Example, Together</a></li>
<li><a href="#section-5">Conclusion</a></li>
</ol>
</div>
<hr class="spacer-large"/>
<section id="section-1">
<h2>1. Understanding the Accessibility-Driven Outline CSS Property:</h2>
<p>Before we explore the accessibility benefits, let&#8217;s grasp the significance of the <span class="code-highlight-secondary">outline</span> property in CSS. This versatile tool empowers us to refine the visual representation of elements without compromising the page layout—an essential consideration in creating inclusive and accessible websites.</p>
</section>
<hr class="spacer-large"/>
<section id="section-2">
<h2>2. Resetting Chrome for Accessibility with <span class="code-highlight-secondary">outline-color: auto;</span>:</h2>
<p>Our first directive aligns with accessibility principles: empower the browser to make a thoughtful choice. By implementing <span class="code-highlight-secondary">outline-color: auto;</span>, we allow Chrome to determine the outline color based on its default settings. This fosters a consistent and inclusive appearance across diverse devices and user preferences.</p>
<div class="codecolorer-container css default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #6666ff;">.element</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">outline-color</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span></div></td></tr></tbody></table></div>
</section>
<hr class="spacer-large"/>
<section id="section-3">
<h2>3. Resetting Chrome with Browser-Specific Accessibility: <span class="code-highlight-secondary">outline-color: -webkit-focus-ring-color;</span>:</h2>
<p>To cater to Chrome&#8217;s unique accessibility features, we leverage the WebKit focus ring color with <span class="code-highlight-secondary">outline-color: -webkit-focus-ring-color;</span>. This declaration ensures that our outline color aligns with Chrome&#8217;s default focus ring, enhancing the accessibility experience without relying on <span class="code-highlight-secondary">!important</span>.</p>
<div class="codecolorer-container css default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #6666ff;">.element</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">outline-color</span><span style="color: #00AA00;">:</span> -webkit-focus-ring-color<span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span></div></td></tr></tbody></table></div>
</section>
<hr class="spacer-large"/>
<section id="section-4">
<h2>4. Code Example, together</h2>
<p>Together, these declarations exemplify a thoughtful approach to styling outlines, prioritizing accessibility and visual cohesion in web design. The flexibility offered accommodates both the browser&#8217;s default styling and browser-specific optimizations, contributing to a seamless and inclusive user experience.</p>
<div class="codecolorer-container css default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #6666ff;">.element</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">outline-color</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">outline-color</span><span style="color: #00AA00;">:</span> -webkit-focus-ring-color<span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span></div></td></tr></tbody></table></div>
</section>
<hr class="spacer-large"/>
<section id="section-5">
<h2>5. Conclusion:</h2>
<p>In the pursuit of optimal web design, accessibility is non-negotiable. By harnessing the potential of the <span class="code-highlight-secondary">outline</span> CSS property and its <span class="code-highlight-secondary">outline-color</span> declarations, we&#8217;ve explored a thoughtful approach to reset Chrome with accessibility in mind. Whether entrusting the browser to decide with <span class="code-highlight-secondary">outline-color: auto;</span> or tailoring our outline to Chrome&#8217;s focus ring with <span class="code-highlight-secondary">outline-color: -webkit-focus-ring-color;</span>, these considerations contribute to a more accessible and user-friendly online experience. Elevate your web design by prioritizing accessibility and embracing the versatility of the outline.</p>
</section>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/css/chrome-reset-with-the-outline-css-property">Chrome Reset with the Outline CSS Property</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/css/chrome-reset-with-the-outline-css-property/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Targeting CSS in the Editor.html for AEM Components for AEMaaCS</title>
		<link>https://sourcedcode.com/blog/aem/targeting-css-in-the-editor-html-for-aem-components-for-aemaacs</link>
					<comments>https://sourcedcode.com/blog/aem/targeting-css-in-the-editor-html-for-aem-components-for-aemaacs#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Fri, 08 Dec 2023 00:31:46 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Development]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=6307</guid>

					<description><![CDATA[<p>Sometimes as developers, we would need to inject some CSS into our pages in the edit-modes to enhance the experience of our authors. One key skill as an AEM developer knowing how to customize the authoring experience in the editor.html (while content authors are editing the page). This article explores the techniques of targeting CSS [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/targeting-css-in-the-editor-html-for-aem-components-for-aemaacs">Targeting CSS in the Editor.html for AEM Components for AEMaaCS</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Sometimes as developers, we would need to inject some CSS into our pages in the edit-modes to enhance the experience of our authors. One key skill as an AEM developer knowing how to customize the authoring experience in the editor.html (while content authors are editing the page). This article explores the techniques of targeting CSS for AEM components in various authoring modes to optimize the content creation process.</p>
<p><strong style="code-highlight-primary">This has only been tested on AEMaaCS.</strong></p>
<div class="mention-block">
  <strong>Quick Links</strong></p>
<ol>
<li><a href="#understanding-authoring-modes">Understanding Authoring Modes in AEM</a></li>
<li><a href="#targeting-components">Targeting Components in Different Authoring Modes</a></li>
<li><a href="#benefits-of-targeting-css">Benefits of Targeting CSS in AEM Editor</a></li>
<li><a href="#conclusion">Conclusion</a></li>
</ol>
</div>
<hr class="spacer-large" />
<h2 id="understanding-authoring-modes">1. Understanding Authoring Modes in AEM:</h2>
<p>AEM&#8217;s editor.html supports multiple authoring modes, each serving a specific purpose in the content creation workflow. These modes include edit mode, preview mode, layout mode, developer mode, MSM (Multi-Site Manager) mode, and time warp mode. To enhance the authoring experience, it&#8217;s crucial to apply targeted CSS to components based on the current authoring mode.</p>
<p><a href="https://sourcedcode.com/wp-content/uploads/2023/12/authoring-modes.png"><img fetchpriority="high" decoding="async" src="https://sourcedcode.com/wp-content/uploads/2023/12/authoring-modes.png" alt="edit mode, preview mode, layout mode, developer mode, MSM (Multi-Site Manager) mode, and time warp mode" width="305" height="297" class="alignnone size-full wp-image-6317" srcset="https://sourcedcode.com/wp-content/uploads/2023/12/authoring-modes.png 305w, https://sourcedcode.com/wp-content/uploads/2023/12/authoring-modes-300x292.png 300w" sizes="(max-width: 305px) 100vw, 305px" /></a></p>
<hr class="spacer-large" />
<h2 id="targeting-components">2. Targeting Components in Different Authoring Modes:</h2>
<p>To achieve a seamless authoring experience, developers can leverage specific CSS classes associated with each authoring mode in AEM. The following example demonstrates how to target a custom component called &#8220;.my-component&#8221; in different authoring modes:</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #66cc66;">/</span>* Edit Mode *<span style="color: #66cc66;">/</span><br />
.aem-AuthorLayer-Edit .my-component <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000066;">background</span>: red;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #66cc66;">/</span>* Preview Mode *<span style="color: #66cc66;">/</span><br />
.aem-AuthorLayer-Preview .my-component <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000066;">background</span>: blue;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #66cc66;">/</span>* Layout Mode *<span style="color: #66cc66;">/</span><br />
.aem-AuthorLayer-Layouting .my-component <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000066;">background</span>: green;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #66cc66;">/</span>* Developer Mode *<span style="color: #66cc66;">/</span><br />
.aem-AuthorLayer-Developer .my-component <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000066;">border</span>: 2px solid yellow;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #66cc66;">/</span>* Time Warp Mode *<span style="color: #66cc66;">/</span><br />
.aem-AuthorLayer-Timewarp .my-component <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;opacity: <span style="color: #cc66cc;">0.7</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #66cc66;">/</span>* MSM Mode *<span style="color: #66cc66;">/</span><br />
.aem-AuthorLayer-MSM .my-component <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000066;">background</span>: purple;<br />
<span style="color: #66cc66;">&#125;</span></div></td></tr></tbody></table></div>
<p>In the above example, each CSS rule targets the &#8220;.my-component&#8221; class in a specific authoring mode, applying distinct styles to improve visibility or provide context for authors working in that mode.</p>
<hr class="spacer-large" />
<h2 id="benefits-of-targeting-css">3. Benefits of Targeting CSS in AEM Editor:</h2>
<ol>
<li><strong>Improved Visibility: </strong>By applying different background colors or borders in various authoring modes, developers can enhance the visibility of components, making it easier for authors to identify and manipulate them.</li>
<li><strong>Contextual Styling: </strong>Tailoring styles based on the authoring mode provides contextual information to content authors. For instance, applying a distinctive style in developer mode can signify that the component is currently being modified at a code level.<br />
Optimized Workflows:</li>
<li><strong>Optimized Workflows: </strong>Targeted CSS in the editor.html file optimizes authoring workflows by reducing confusion and streamlining the content creation process. Authors can quickly grasp the current mode and focus on the relevant tasks.
</li>
</ol>
<hr class="spacer-large" />
<h2 id="conclusion">4. Conclusion:</h2>
<p>Customizing the authoring experience in AEM by targeting CSS in the editor.html file is a powerful way to enhance usability and streamline content creation workflows. By understanding and leveraging the specific CSS classes associated with each authoring mode, developers can provide a more intuitive and visually informative environment for content authors using AEMaaCS.</p>
<p><em>And one more last thing to note is, please ensure that these rules are added into your clientlibs.author structure, so that these rules will never be exposed on production.</em></p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/targeting-css-in-the-editor-html-for-aem-components-for-aemaacs">Targeting CSS in the Editor.html for AEM Components for AEMaaCS</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/targeting-css-in-the-editor-html-for-aem-components-for-aemaacs/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>HTML element style tag validation approaches in 2023</title>
		<link>https://sourcedcode.com/blog/css/html-element-style-tag-validation-approaches-in-2023</link>
					<comments>https://sourcedcode.com/blog/css/html-element-style-tag-validation-approaches-in-2023#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sun, 30 Jul 2023 18:58:35 +0000</pubDate>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[General Web]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=5484</guid>

					<description><![CDATA[<p>In the rapidly changing world of web development, it&#8217;s essential to keep up with the latest standards. Some ways of inserting &#60;style&#62; tag to the HTML document are not valid for HTML5. In this article we will go through different compliant methods to insert &#60;style&#62; tags to your HTML documents. Although there are some invalid [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/css/html-element-style-tag-validation-approaches-in-2023">HTML element style tag validation approaches in 2023</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In the rapidly changing world of web development, it&#8217;s essential to keep up with the latest standards. Some ways of inserting &lt;style&gt; tag to the HTML document are not valid for HTML5. In this article we will go through different compliant methods to insert &lt;style&gt; tags to your HTML documents. Although there are some invalid ways of inserting the &lt;style&gt; tag, we will explore some alternatives that adhere to the current HTML5 standards.</p>
<div class="mention-block">
<strong>Quick Links</strong></p>
<ol>
<li><a href="#external-stylesheets-valid">External Stylesheets (valid)</a></li>
<li><a href="#inline-style-tag-in-head">Inline &lt;style&gt; tag in the &lt;head&gt; (valid)</a></li>
<li><a href="#inline-style-tag-in-body">Inline &lt;style&gt; tag in the &lt;body&gt; (in-valid), but acceptable.</a></li>
</ol>
</div>
<hr class="spacer-larger"/>
<h2 id="external-stylesheets-valid">1. External Stylesheets (valid)</h2>
<p>One of the most common and recommended ways to style web pages is by using external stylesheets. Instead of adding styles directly into the HTML, you create a separate CSS file and link it to your web page. This keeps your HTML clean and separates the style rules from the content, making it easier to manage and reuse styles across multiple pages.</p>
<p>To link an external stylesheet, use the following code within the &lt;head&gt; section of your HTML document:</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;styles.css&quot;</span>&gt;</div></td></tr></tbody></table></div>
<hr class="spacer-larger"/>
<h2 id="inline-style-tag-in-head">2. Inline &lt;style&gt; tag in the &lt;head&gt; (valid)</h2>
<p>Another valid method is to use inline styles in the &lt;head&gt; section. If you have styles that are specific to a single page and won&#8217;t be reused elsewhere, you can write your CSS directly in the &lt;head&gt;. This ensures that your styles are loaded before the page content, preventing any unwanted visual glitches.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&lt;!DOCTYPE html&gt;<br />
&lt;<span style="color: #000000; font-weight: bold;">html</span>&gt;<br />
&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;<br />
&nbsp; &lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;My Page&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;<br />
&nbsp; &lt;<span style="color: #000000; font-weight: bold;">style</span>&gt;<br />
&nbsp; &nbsp; <span style="color: #66cc66;">/</span>* Your CSS <span style="color: #000066;">rules</span> here *<span style="color: #66cc66;">/</span><br />
&nbsp; &lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">style</span>&gt;<br />
&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;<br />
&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;<br />
&nbsp; &lt;!-- Your page <span style="color: #000066;">content</span> here --&gt;<br />
&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;<br />
&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</div></td></tr></tbody></table></div>
<hr class="spacer-larger"/>
<h2 id="inline-style-tag-in-body">3. Inline &lt;style&gt; tag in the &lt;body&gt; (in-valid), but acceptable.</h2>
<p>A &lt;style&gt; tag within the &lt;body&gt; tag won’t validate because the HTML specs say it can’t be there. The reason behind this restriction is to maintain a clear separation of concerns between the content (HTML) and the presentation (CSS). Placing &lt;style&gt; tags within the &lt;body&gt; goes against the principles of well-structured and maintainable HTML documents. </p>
<p>Try running the code below in <a href="https://validator.w3.org/#validate_by_input" rel="noopener" target="_blank">https://validator.w3.org/#validate_by_input</a>, and you should able to see the error.</p>
<div class="mention-block">
<h5>Can I still use the &lt;style&gt; tag inside of the &lt;body&gt; tag?</h5>
<p>Using the &lt;style&gt; tag directly inside the &lt;body&gt; tag is not a valid approach according to the HTML5 specification. The official HTML5 specification strictly defines the placement of the &lt;style&gt; tag within the &lt;head&gt; element, specifically to separate content (HTML) from presentation (CSS).</p>
<p>However, placing &lt;style&gt; tags in the &lt;body&gt; will work in most modern browsers, but it is considered non-compliant. This approach however is still used by many websites out there. Especially with CMS platforms like WordPress, Drupal, Site-core, and Adobe Experience Managers, full-filling features and UX for simple scenarios, it is acceptable&#8230; The thing is, even thought we have HTML5 specification, even Google <a href="https://www.hobo-web.co.uk/official-google-prefers-valid-html-css/#:~:text=While%20Google%20recommends%20we%20use,it%20is%20to%20the%20query." rel="noopener" target="_blank">(source)</a> themselves are taking shortcuts to cut down performance costs.</p>
<p>Note: While Google recommends we use W3C validation, Google doesn&#8217;t rank valid html and css pages above invalid pages. If Google can crawl and render a page Google will rank the page appropriately based on how relevant it is to the query. <a href="https://www.hobo-web.co.uk/official-google-prefers-valid-html-css/#:~:text=While%20Google%20recommends%20we%20use,it%20is%20to%20the%20query." rel="noopener" target="_blank">source.</a>
</div>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&lt;!DOCTYPE html&gt;<br />
&lt;<span style="color: #000000; font-weight: bold;">html</span>&gt;<br />
&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;<br />
&nbsp; &lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;My Page&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;<br />
&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;<br />
&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;<br />
&nbsp; &lt;!-- Your page <span style="color: #000066;">content</span> here --&gt;<br />
&nbsp; &lt;<span style="color: #000000; font-weight: bold;">style</span>&gt;<br />
&nbsp; &nbsp; * Your CSS <span style="color: #000066;">rules</span> here *<span style="color: #66cc66;">/</span><br />
&nbsp; &lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">style</span>&gt;<br />
&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;<br />
&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</div></td></tr></tbody></table></div>
<hr class="spacer-larger"/>
<h2>Summary</h2>
<p>Following W3C standards in web development brings positive outcomes such as improved cross-browser compatibility, accessibility, future-proofing, and maintainability. It also fosters interoperability, boosts SEO performance, enhances security, and contributes to a positive reputation. Embracing W3C standards ensures a faster development process and a healthier web ecosystem.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/css/html-element-style-tag-validation-approaches-in-2023">HTML element style tag validation approaches in 2023</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/css/html-element-style-tag-validation-approaches-in-2023/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Add inline CSS with AEM Sightly</title>
		<link>https://sourcedcode.com/blog/aem/add-inline-css-with-aem-sightly</link>
					<comments>https://sourcedcode.com/blog/aem/add-inline-css-with-aem-sightly#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Tue, 13 Jun 2023 12:20:51 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[CSS]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=5314</guid>

					<description><![CDATA[<p>AEM Sightly is a templating language that simplifies the integration of HTML and server-side logic. One of the key features of Sightly is the ability to use add inline-css to the component itself, so that your user experience requirements can be full-filed. In this article, we will explore how AEM Sightly enables developers to apply [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/add-inline-css-with-aem-sightly">Add inline CSS with AEM Sightly</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>AEM Sightly is a templating language that simplifies the integration of HTML and server-side logic. One of the key features of Sightly is the ability to use add inline-css to the component itself, so that your user experience requirements can be full-filed. In this article, we will explore how AEM Sightly enables developers to apply inline styles to elements dynamically, enhancing the flexibility and efficiency of web development.</p>
<div class="mention-block">
<strong>Quick Links</strong></p>
<ol>
<li><a href="#inline-css-with-aem-sightly">Inline CSS with AEM Sightly</a></li>
<li><a href="#dynamic-styling-with-css-via-style-tag">Dynamic Styling with CSS via &lt;style&gt; tag</a></li>
</ol>
</div>
<hr class="spacer-large" />
<h2 id="inline-css-with-aem-sightly">1. Inline CSS with AEM Sightly</h2>
<p>AEM Sightly allows developers to apply inline CSS to HTML elements using dynamic content. By leveraging the ${properties.maxHeight @ context=&#8221;styleString&#8221;}, developers can set the max-height property of an element based on the value of the maxHeight property defined in the AEM component dialog.</p>
<p>Consider the following example:</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;${models.id}&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cmp-container&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;max-height: ${properties.maxHeight @ context=&quot;</span>styleString<span style="color: #ff0000;">&quot;}px&quot;</span>&gt;</span><br />
&nbsp; <span style="color: #808080; font-style: italic;">&lt;!-- Your content here --&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span><br />
<br />
<br />
//output<br />
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;${models.id}&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cmp-container&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;max-height: 300px&quot;</span>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></div></td></tr></tbody></table></div>
<p>In this code snippet, the max-height property is set inline using the ${properties.maxHeight} value defined in the component&#8217;s dialog. The @ context=&#8221;styleString&#8221; ensures that the value is properly processed as a style string.</p>
<p><strong>2. Benefits of Dynamic Inline CSS</strong></p>
<p>Using ${properties.maxHeight @ context=&#8221;styleString&#8221;} for inline CSS with AEM Sightly offers several advantages:</p>
<ol>
<li>Flexibility: Inline CSS allows developers to adapt styles based on user inputs or system properties, making web pages more dynamic and responsive.</li>
<li>Efficiency: By defining styles dynamically within the component code, developers can reduce the need for separate CSS rules and enhance the component&#8217;s reusability.</li>
<li>Component-Level Customization: With dynamic inline CSS, component properties like maxHeight can be set individually for each instance of the component, granting greater customization.</li>
</ol>
<hr class="spacer-larger" />
<h2 id="dynamic-styling-with-css-via-style-tag">2. Dynamic Styling with CSS via &lt;style&gt; tag</h2>
<p>In addition to using inline styles, AEM Sightly also allows dynamic styling through CSS. By incorporating the ${models.id} and ${properties.maxHeight @ context=&#8221;styleString&#8221;} within a &lt;style&gt; block, developers can create more sophisticated and reusable styling rules.</p>
<div class="codecolorer-container css default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&lt;style<span style="color: #00AA00;">&gt;</span><br />
&nbsp; <span style="color: #808080; font-style: italic;">/* Style for the element with the given id (${models.id}) */</span><br />
&nbsp; #$<span style="color: #00AA00;">&#123;</span>models.id<span style="color: #00AA00;">&#125;</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">max-height</span><span style="color: #00AA00;">:</span> $<span style="color: #00AA00;">&#123;</span>properties<span style="color: #6666ff;">.maxHeight</span> @ context<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;styleString&quot;</span><span style="color: #00AA00;">&#125;</span>px<span style="color: #00AA00;">;</span><br />
&nbsp; <span style="color: #00AA00;">&#125;</span><br />
&lt;/style<span style="color: #00AA00;">&gt;</span><br />
<br />
<br />
// output<br />
&lt;style<span style="color: #00AA00;">&gt;</span><br />
&nbsp; <span style="color: #cc00cc;">#cmp-container1231432324234</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">max-height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span><br />
&nbsp; <span style="color: #00AA00;">&#125;</span><br />
&lt;/style<span style="color: #00AA00;">&gt;</span></div></td></tr></tbody></table></div>
<div class="mention-block">
It&#8217;s important to understand the HTML element &lt;style&gt; tag validation approaches in 2023. <a href="https://sourcedcode.com/blog/aem/add-inline-css-with-aem-sightly" rel="noopener" target="_blank">Click here</a> to learn more about &lt;style&gt; tag validation approaches in 2023.</p>
<p>Utilizing the Sightly HTL 1.4 API, @context, will protect against cross-site scripting (XSS) vulnerabilities, HTL automatically recognises the context within which an output string is to be displayed within the final HTML output, and escapes that string appropriately. <a href="https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#12-available-expression-options" rel="noopener" target="_blank">reference</a>.</p>
</div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/add-inline-css-with-aem-sightly">Add inline CSS with AEM Sightly</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/add-inline-css-with-aem-sightly/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What is BEM? What are some examples?</title>
		<link>https://sourcedcode.com/blog/css/what-is-bem-with-examples</link>
					<comments>https://sourcedcode.com/blog/css/what-is-bem-with-examples#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Thu, 13 Jan 2022 06:53:58 +0000</pubDate>
				<category><![CDATA[CSS]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=3169</guid>

					<description><![CDATA[<p>In short, CSS BEM is a CSS naming convention for HTML classNames that allows developers to write CSS faster and maintain CSS more easily. CSS BEM uses compound names for CSS classes, those being &#8220;block__element&#8211;modifier&#8221;. BEM is very popular when working on HTML components. An HTML component is nothing but a group of HTML elements [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/css/what-is-bem-with-examples">What is BEM? What are some examples?</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In short, CSS BEM is a CSS naming convention for HTML classNames that allows developers to write CSS faster and maintain CSS more easily. CSS BEM uses compound names for CSS classes, those being &#8220;block__element&#8211;modifier&#8221;. BEM is very popular when working on HTML components. An HTML component is nothing but a group of HTML elements that forms a useful entity. BEM supplies a modular structure to your HTML &#038; CSS Components. Because of its unique naming strategy, we won’t run into altercations with other CSS names. </p>
<div class="mention-block">
<p><strong>Block, Element, Modifier, CSS methodology</strong></p>
<p>Here’s an example of what a CSS developer writing in the BEM style might look like:</p>
<div class="codecolorer-container css default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #6666ff;">.block</span><br />
<span style="color: #6666ff;">.block__element</span><br />
.block__element<span style="color: #444;">--modifier</span></div></td></tr></tbody></table></div>
<p><span class="code-highlight-primary">.block</span><br />
<strong>Block </strong>is a top-level abstraction of a new component; this block should be thought of as a parent.</p>
<p>.block<span class="code-highlight-primary">__element</span><br />
<strong>Element </strong>prefixed with double under__scores, are CSS selectors to identify child elements; we can use these CSS selectors to target elements with more control.</p>
<p>.block__element<span class="code-highlight-primary">&#8211;modifier</span><br />
<strong>Modifier </strong>prefixed with double &#8212; dash, are CSS selectors that identify variations of a particular element. This is used to manipulate the theme or style that a particular component without changing the look and feel of the default component itself.
</div>
<p>In this article, we will be showing examples and topics of this BEM, CSS methodology.</p>
<p>Use the links below to jump to each topic or example:</p>
<ol>
<li><a href="#valid-bem-naming">Valid BEM Class Naming</a></li>
<li><a href="#simple-example">Simple Example</a></li>
<li><a href="#advance-example">Advance Example</a></li>
<li><a href="#grandchild-example">Complicated Grand Children Structure</a></li>
<li><a href="#utility-bem">Utility Classes with BEM</a></li>
</ol>
<hr class="spacer-larger"/>
<h2 id="valid-bem-naming">1. Valid BEM Class Naming</h2>
<ul>
<li>
<p>Names are written in lowercase Latin letters.</p>
</li>
<li>
<p>Words are separated by a hyphen -.</p>
</li>
<li>
<p>The block name defines the <a class="article__link" href="https://en.wikipedia.org/wiki/Namespace">namespace</a> for its elements and modifiers.</p>
</li>
<li>
<p>The element name is separated from the block name by a double underscore __.</p>
</li>
<li>
<p>The modifier name is separated from the block or element name by two double dashes &#8211;.</p>
</li>
</ul>
<div class="codecolorer-container css default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #6666ff;">.block</span><br />
<span style="color: #6666ff;">.block__element</span><br />
.block__element<span style="color: #444;">--modifier</span><br />
<br />
<span style="color: #6666ff;">.hero-text</span><br />
<span style="color: #6666ff;">.hero-text__sticky</span><br />
<span style="color: #6666ff;">.hero-text__sticky-card</span><br />
<span style="color: #6666ff;">.hero-text__sticky-card-button</span><br />
<span style="color: #6666ff;">.hero-text__sticky-flag</span><br />
<span style="color: #6666ff;">.hero-text__sticky-flag-picker</span><br />
<span style="color: #6666ff;">.hero-text__sticky-flag-links</span><br />
<span style="color: #6666ff;">.hero-text__sticky-flag-links-link</span><br />
<span style="color: #6666ff;">.hero-text__sticky-container</span><br />
<span style="color: #6666ff;">.hero-text__sticky-container<span style="color: #444;">--primary</span></span><br />
<span style="color: #6666ff;">.hero-text__sticky-container<span style="color: #444;">--secondary</span></span><br />
<span style="color: #6666ff;">.hero-text__sticky-container<span style="color: #444;">--primary-large</span></span><br />
<span style="color: #6666ff;">.hero-text__sticky-container<span style="color: #444;">--secondary-large</span></span><br />
<span style="color: #6666ff;">.hero-text__sticky-container-left</span><br />
.hero-text__sticky-container-right<br />
<br />
<span style="color: #6666ff;">.text-with-image</span><br />
<span style="color: #6666ff;">.text-with-image__container</span><br />
<span style="color: #6666ff;">.text-with-image__container-33</span><br />
<span style="color: #6666ff;">.text-with-image__container-33-first</span><br />
<span style="color: #6666ff;">.text-with-image__container-33-second</span><br />
<span style="color: #6666ff;">.text-with-image__container-33-third</span><br />
<span style="color: #6666ff;">.text-with-image__card-primary</span><br />
<span style="color: #6666ff;">.text-with-image__card-secondary</span><br />
.text-with-image__card-tertiary</div></td></tr></tbody></table></div>
<hr class="spacer-larger"/>
<h2 id="simple-example">2. Simple Example</h2>
<p>In this simple example, we showcase an HTML card component. The top-level is set with the <span class="code-highlight-secondary">.card</span> className; this is the <span class="code-highlight-primary">Block</span>. </p>
<p>Child items or <span class="code-highlight-primary">Elements</span> inside of .card is prefixed with <span class="code-highlight-secondary">.card__</span>. You will realize that <span class="code-highlight-secondary">.card__description</span> is declared. </p>
<p>Next, we have two buttons. They both have a similar look and feel, but the only difference is the background colors, and the width of the buttons. With these two different button variations, we can use the <span class="code-highlight-primary">Modifiers</span> conventention in BEM; here, we prefix the Modifier with <span class="code-highlight-secondary">.card__button</span>, and then add double &#8212; dash, and then the modifier name; example: <span class="code-highlight-secondary">.card__button&#8211;submit</span> &#038;&#038; <span class="code-highlight-secondary">.card__button&#8211;cancel</span>.</p>
<p><a class="foobox fbx-link fbx-instance" href="https://sourcedcode.com/wp-content/uploads/2022/01/bem-simple-example.1.png"><img decoding="async" src="https://sourcedcode.com/wp-content/uploads/2022/01/bem-simple-example.1.png" alt="Simple Example" data-caption-desc="Simple Example" /></a></p>
<h5>HTML</h5>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;card&quot;</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;card__image&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;card__description&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">button</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;card__button--submit&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">button</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">button</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;card__button--cancel&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">button</span>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></div></td></tr></tbody></table></div>
<div class="b-layout">
<div class="b-layout__50">
<h5>SCSS</h5>
<div class="codecolorer-container css default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #6666ff;">.card</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; // <span style="color: #9932cc;">image</span><br />
&nbsp; &amp;__image <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><br />
&nbsp; <span style="color: #00AA00;">&#125;</span><br />
&nbsp; // description<br />
&nbsp; &amp;__description <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><br />
&nbsp; <span style="color: #00AA00;">&#125;</span><br />
&nbsp; // <span style="color: #993333;">button</span><br />
&nbsp; &amp;__button <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; &amp;<span style="color: #444;">--submit</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline-block</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #00AA00;">&#125;</span><br />
&nbsp; &nbsp; &amp;<span style="color: #444;">--cancel</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline-block</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #00AA00;">&#125;</span><br />
&nbsp; <span style="color: #00AA00;">&#125;</span><br />
<span style="color: #00AA00;">&#125;</span></div></td></tr></tbody></table></div>
</div>
<div class="b-layout__50">
<h5>CSS Output</h5>
<div class="codecolorer-container css default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #6666ff;">.card__image</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span><br />
<span style="color: #6666ff;">.card__description</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span><br />
<span style="color: #6666ff;">.card__button<span style="color: #444;">--submit</span></span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline-block</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span><br />
<span style="color: #6666ff;">.card__button<span style="color: #444;">--cancel</span></span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline-block</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span></div></td></tr></tbody></table></div>
</div>
</div>
<hr class="spacer-larger"/>
<h2 id="advance-example">3. Advance Example</h2>
<p>In this more complicated example, we showcase an HTML post-card component. The top-level is set with the <span class="code-highlight-secondary">.post-card</span> className; this is the <span class="code-highlight-primary">Block</span>. </p>
<p>Child items or <span class="code-highlight-primary">Elements</span> inside of <span class="code-highlight-secondary">.post-card</span> is prefixed with <span class="code-highlight-secondary">.post-card__</span>. You will realize that there are an abundance of elements inside of the <span class="code-highlight-secondary">.post-card</span> component. Here listed some examples are: <span class="code-highlight-secondary">.post-card__input-container</span>, <span class="code-highlight-secondary">.post-card__profile</span>, <span class="code-highlight-secondary">.post-card__profile-photo</span>.</p>
<div class="mention-block">Please realize that working with BEM, all classNames are flat, meaning that there will only be allowed with once __, underscore underscore. This CSS methodology was developer by <a href="https://en.bem.info/" rel="noopener" target="_blank">Yandex</a>; I do have some questions myself about this.</div>
<p>Next, I am going to highlight the <span class="code-highlight-primary">Modifiers</span> CSS classNames in this example. You will realize that there are three buttons for this given component. We have live-video, photo-video, and live-event buttons. It is safe to say that these buttons are very similar and have a slight variation to them. It is a good call to use <span class="code-highlight-primary">Modifiers</span> for these buttons; prefixed by .post-card__btn</span>, we now append double dash &#8212; and have the CSS classNames like <span class="code-highlight-secondary">.post-card__btn&#8211;live-video</span>,<span class="code-highlight-secondary">.post-card__btn&#8211;photo-video</span>, <span class="code-highlight-secondary">.post-card__btn&#8211;life-event</span>.</p>
<p><a class="foobox fbx-link fbx-instance" href="https://sourcedcode.com/wp-content/uploads/2022/01/bem-advanced-example.1.png"><img decoding="async" src="https://sourcedcode.com/wp-content/uploads/2022/01/bem-advanced-example.1.png" alt="Advance Example" data-caption-desc="Advance Example" /></a></p>
<h5>HTML</h5>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post-card&quot;</span>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post-card__input-container&quot;</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post-card__profile&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post-card__profile-photo&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post-card__search&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> <span style="color: #000066;">action</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post-card__search-form&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post-card__search-input&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post-card__actions-container&quot;</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post-card__action&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">button</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post-card__btn--live-video&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">button</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post-card__action&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">button</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post-card__btn--photo-video&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">button</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post-card__action&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">button</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post-card__btn--live-event&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">button</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></div></td></tr></tbody></table></div>
<div class="b-layout">
<div class="b-layout__50">
<h5>SCSS</h5>
<div class="code-500">
<div class="codecolorer-container css default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #6666ff;">.post-card</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; // input container<br />
&nbsp; &nbsp; &amp;__input-container <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> flex<span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #00AA00;">&#125;</span><br />
&nbsp; &nbsp; &amp;__profile<span style="color: #00AA00;">,</span> &amp;__search <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">50%</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #00AA00;">&#125;</span><br />
&nbsp; &nbsp; // profile<br />
&nbsp; &nbsp; &amp;__profile <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &amp;-photo <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00AA00;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #00AA00;">&#125;</span><br />
&nbsp; &nbsp; // search<br />
&nbsp; &nbsp; &amp;__search <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &amp;-form <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00AA00;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &amp;-form <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00AA00;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #00AA00;">&#125;</span><br />
&nbsp; &nbsp; // actions container<br />
&nbsp; &nbsp; &amp;__actions-container <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> flex<span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #00AA00;">&#125;</span><br />
&nbsp; &nbsp; &amp;__action <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">33%</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #00AA00;">&#125;</span><br />
&nbsp; &nbsp; // action buttons<br />
&nbsp; &nbsp; &nbsp;&amp;__btn <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &amp;<span style="color: #444;">--live-video</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00AA00;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &amp;<span style="color: #444;">--photo-video</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00AA00;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &amp;<span style="color: #444;">--life-event</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00AA00;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #00AA00;">&#125;</span><br />
<span style="color: #00AA00;">&#125;</span></div></td></tr></tbody></table></div>
</div>
</div>
<div class="b-layout__50">
<h5>CSS Output</h5>
<div class="code-500">
<div class="codecolorer-container css default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #6666ff;">.post-card</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span><br />
<span style="color: #6666ff;">.post-card__input-container</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> flex<span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span><br />
<span style="color: #6666ff;">.post-card__profile</span><span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.post-card__search</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">50%</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span><br />
<span style="color: #6666ff;">.post-card__profile</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span><br />
<span style="color: #6666ff;">.post-card__profile-photo</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span><br />
<span style="color: #6666ff;">.post-card__search</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span><br />
<span style="color: #6666ff;">.post-card__search-form</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span><br />
<span style="color: #6666ff;">.post-card__search-form</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span><br />
<span style="color: #6666ff;">.post-card__actions-container</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> flex<span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span><br />
<span style="color: #6666ff;">.post-card__action</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">33%</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span><br />
<span style="color: #6666ff;">.post-card__btn<span style="color: #444;">--live-video</span></span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span><br />
<span style="color: #6666ff;">.post-card__btn<span style="color: #444;">--photo-video</span></span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span><br />
<span style="color: #6666ff;">.post-card__btn<span style="color: #444;">--life-event</span></span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span></div></td></tr></tbody></table></div>
</div>
</div>
</div>
<hr class="spacer-larger"/>
<h2 id="grandchild-example">4. Complicated Grand Children Structure</h2>
<p>According to BEM method, block structure should be flattened; you do not need to reflect nested DOM structure of the block. So, the class names for this case would be:</p>
<div class="codecolorer-container css default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&lt;div class<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;block&quot;</span><span style="color: #00AA00;">&gt;</span><br />
&nbsp; &nbsp; &lt;div class<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;block__elem-1&quot;</span><span style="color: #00AA00;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;&lt;div class<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;block__elem-2&quot;</span><span style="color: #00AA00;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div class<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;block__elem-3&quot;</span><span style="color: #00AA00;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;div class<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;block__elem-4&quot;</span><span style="color: #00AA00;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;<span style="color: #993333;">button</span> class<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;block__elem-5--red&quot;</span><span style="color: #00AA00;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;span class<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;block__elem-6&quot;</span><span style="color: #00AA00;">&gt;</span>&lt;/span<span style="color: #00AA00;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/button<span style="color: #00AA00;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;<span style="color: #993333;">button</span> class<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;block__elem-5--blue&quot;</span><span style="color: #00AA00;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;span class<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;block__elem-6&quot;</span><span style="color: #00AA00;">&gt;</span>&lt;/span<span style="color: #00AA00;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/button<span style="color: #00AA00;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/div<span style="color: #00AA00;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;div class<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;block__elem-7&quot;</span><span style="color: #00AA00;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;ul class<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;block__elem-8&quot;</span><span style="color: #00AA00;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;li class<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;block__elem-9&quot;</span><span style="color: #00AA00;">&gt;</span>&lt;/li<span style="color: #00AA00;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;li class<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;block__elem-9&quot;</span><span style="color: #00AA00;">&gt;</span>&lt;/li<span style="color: #00AA00;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;li class<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;block__elem-9&quot;</span><span style="color: #00AA00;">&gt;</span>&lt;/li<span style="color: #00AA00;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/ul<span style="color: #00AA00;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/div<span style="color: #00AA00;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/div<span style="color: #00AA00;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;&lt;/div<span style="color: #00AA00;">&gt;</span><br />
&nbsp; &nbsp; &lt;/div<span style="color: #00AA00;">&gt;</span><br />
&nbsp;&lt;/div<span style="color: #00AA00;">&gt;</span></div></td></tr></tbody></table></div>
<hr class="spacer-larger"/>
<h2 id="utility-bem">5. Utility Classes with BEM</h2>
<p>Let&#8217;s not twist our arms and say the flat naming convention is a rule set to stone. I understand that the examples in this article only show components that use BEM naming conventions, but you are probably wondering, how about utility classes? </p>
<p>Elements that are hard to identify with a new, meaningful class name (e.g., you need a parent element with a position: relative → create &lt;div class=&#8221;position-relative&#8221;&gt;&lt;div class=&#8221;card&#8221;&gt;&lt;/div&gt;&lt;/div&gt;) or uikits imported from other libraries can be used as well.</p>
<p>Utility classes speed up the CSS implementation and make it more manageable to customize things. Utilities like the BassCSS margin utility, example:</p>
<div class="codecolorer-container css default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #6666ff;">.m0</span> &nbsp;<span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #cc66cc;">0</span> <span style="color: #00AA00;">&#125;</span><br />
<span style="color: #6666ff;">.mt0</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span> &nbsp; &nbsp;<span style="color: #cc66cc;">0</span> <span style="color: #00AA00;">&#125;</span><br />
<span style="color: #6666ff;">.mr0</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span> &nbsp;<span style="color: #cc66cc;">0</span> <span style="color: #00AA00;">&#125;</span><br />
<span style="color: #6666ff;">.mb0</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #00AA00;">&#125;</span><br />
...<br />
<br />
<span style="color: #6666ff;">.pr0</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">padding-right</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #00AA00;">&#125;</span><br />
<span style="color: #6666ff;">.pb0</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">padding-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #00AA00;">&#125;</span><br />
<span style="color: #6666ff;">.pl0</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">padding-left</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #00AA00;">&#125;</span><br />
<span style="color: #6666ff;">.px0</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">padding-left</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding-right</span><span style="color: #00AA00;">:</span> &nbsp;<span style="color: #cc66cc;">0</span> <span style="color: #00AA00;">&#125;</span><br />
<span style="color: #6666ff;">.py0</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">padding-top</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> &nbsp;<span style="color: #000000; font-weight: bold;">padding-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #00AA00;">&#125;</span><br />
...</div></td></tr></tbody></table></div>
<p><strong>Utility classes in conjunction used with BEM looks like:</strong></p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;card mt12&quot;</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;card__image&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;card__description pl0 pb0&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">i</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'fas fa-arrows-alt-v'</span>&gt;</span>fa-arrows-alt-v<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">i</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">button</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;card__button--submit pl0&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">button</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">button</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;card__button--cancel pl0&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">button</span>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></div></td></tr></tbody></table></div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/css/what-is-bem-with-examples">What is BEM? What are some examples?</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/css/what-is-bem-with-examples/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
