Skip to content

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Category: HTML

HTML

HTML: Use Semantic HTML5 Elements for Better SEO and Accessibility

- 30.03.26 - ErcanOPAK comment on HTML: Use Semantic HTML5 Elements for Better SEO and Accessibility

๐Ÿ“ Meaningful HTML Markup Everything is a div? Search engines confused, screen readers lost. Semantic HTML5 uses elements that describe their purpose: <header>, <nav>, <article>, <section>. Better SEO, better accessibility. The Div Soup Problem Home About … Article Title … ยฉ 2024 Semantic HTML5 Solution Home About … Article Title Article content… Section Heading Section […]

Read More
HTML

HTML5: Use Semantic Elements for Better SEO and Accessibility

- 22.03.26 - ErcanOPAK comment on HTML5: Use Semantic Elements for Better SEO and Accessibility

๐ŸŽฏ Meaningful HTML, Better Rankings div soup everywhere? Google confused, screen readers lost. Semantic HTML tells machines what content means. The Div Soup Problem Home My Article Article content… ยฉ 2024 Semantic HTML Home My Article Article content… ยฉ 2024 ๐Ÿ“š Essential Semantic Elements Element Purpose <header> Top of page/section <nav> Navigation links <main> Main […]

Read More
HTML

HTML5: Use for Art Direction and Responsive Images

- 19.03.26 - ErcanOPAK comment on HTML5: Use for Art Direction and Responsive Images

๐Ÿ–ผ๏ธ Serve Perfect Image for Every Device Desktop gets landscape. Mobile gets portrait. WebP for modern browsers, JPEG fallback. <picture> handles it all. Basic Responsive Images Art Direction (Different Crops) ๐ŸŽฏ Advanced: Resolution + Format ๐Ÿ’ก Why Use <picture>? Performance: Serve WebP (30% smaller) to supporting browsers Art Direction: Show different crops on different screens […]

Read More
HTML

HTML5: Use
for Accordion Without JavaScript

- 19.03.26 | 19.03.26 - ErcanOPAK comment on HTML5: Use
for Accordion Without JavaScript

Building FAQ accordion? Writing 50 lines of JavaScript? HTML does it natively. What is HTML5?   HTML5 is the latest version of HTML…     Already expanded   Use ‘open’ attribute to start expanded     Features: Click to expand/collapse. Keyboard accessible. SEO-friendly (content readable by search engines). Style: Use CSS to customize summary arrow, […]

Read More
HTML

HTML5: Use for Autocomplete Without JavaScript

- 19.03.26 | 19.03.26 - ErcanOPAK comment on HTML5: Use for Autocomplete Without JavaScript

๐Ÿ“ Native Autocomplete Building autocomplete dropdown? No React Select needed. HTML does it natively. Dynamic Options: Populate datalist with JavaScript/API. Still native rendering. Browser Support: 97% (all modern browsers). Benefit: Zero bytes JavaScript, accessible by default, mobile keyboard optimized.

Read More
HTML

HTML5: Creating Modern FAQ Accordions Without JavaScript

- 01.03.26 - ErcanOPAK comment on HTML5: Creating Modern FAQ Accordions Without JavaScript

๐Ÿš€ Lightweight UI Don’t load heavy JS libraries for simple accordions. Use the native <details> element. Is this SEO Friendly? Yes! Google crawls content inside details tags even when they are closed. It’s clean, accessible, and works on every browser perfectly.

Read More
HTML

HTML5: Encapsulating Styles with Shadow DOM and Web Components

- 01.03.26 - ErcanOPAK comment on HTML5: Encapsulating Styles with Shadow DOM and Web Components

๐Ÿ—๏ธ The Architecture of Web Components Avoid CSS collisions forever. Shadow DOM allows you to attach a ‘private’ DOM tree to an element that cannot be accessed by global CSS. const host = document.querySelector(‘#host’); const shadowRoot = host.attachShadow({mode: ‘closed’}); shadowRoot.innerHTML = ‘Private Text’; This is the standard for building reusable UI libraries that work across […]

Read More
HTML

HTML5: Real Art Direction with the Element

- 01.03.26 - ErcanOPAK comment on HTML5: Real Art Direction with the Element

Don’t just resize images; change them. The <picture> element allows for ‘Art Direction’. This ensures mobile users see a tight, meaningful crop while desktop users see the full cinematic landscape, optimizing both UX and bandwidth.

Read More
HTML

HTML5: Predicting the User’s Next Move with

- 28.02.26 - ErcanOPAK comment on HTML5: Predicting the User’s Next Move with

What if the next page the user clicks on loads instantly? You can achieve this by prefetching assets. The Strategy: Use this on your ‘Home’ page to pre-load the ‘Pricing’ or ‘Login’ pages. The browser downloads them in the background during idle time.

Read More
HTML

HTML5: Building Native Modals with the Element

- 28.02.26 - ErcanOPAK comment on HTML5: Building Native Modals with the Element

Forget heavy JavaScript modal libraries. HTML5 now has a native <dialog> element with a built-in backdrop. This is a native modal! Close Open Pro Advantage: It automatically handles focus management and ‘Escape’ key closing, which is vital for accessibility (A11y).

Read More
HTML

HTML5: Speed Up Your LCP with Native loading=’lazy’

- 28.02.26 - ErcanOPAK comment on HTML5: Speed Up Your LCP with Native loading=’lazy’

Don’t rely on JavaScript libraries for lazy loading. HTML5 now does it natively. The Result: The browser only downloads these assets when the user is about to scroll to them, saving 60%+ in initial page weight.

Read More
HTML

HTML5 Forms: The Built-In Validation That Replaced jQuery Validate

- 23.02.26 | 23.02.26 - ErcanOPAK comment on HTML5 Forms: The Built-In Validation That Replaced jQuery Validate

๐Ÿ“ The 10KB JavaScript Library You Don’t Need We used to load jQuery + jQuery Validate (45KB) just to validate emails. Now? Zero JavaScript. Native HTML does it all. The Power of Native Validation ๐ŸŽฏ All The Validation You Need (No JS) <form> <!– Email validation –> <input type=”email” required placeholder=”Email”> <!– URL validation –> […]

Read More
HTML

HTML5: Use the dialog Element for Native Modal Dialogs

- 22.02.26 | 22.02.26 - ErcanOPAK comment on HTML5: Use the dialog Element for Native Modal Dialogs

Building modals with divs and JavaScript is complex. HTML5 dialog element provides native modal functionality. Basic Usage:   Modal Title   Modal content here Close   Open Modal Features: Automatic backdrop, ESC key closes, focus trap, accessible by default! Styling: dialog::backdrop for backdrop styling. Fully customizable with CSS. Native, accessible, no library needed!

Read More
HTML

HTML5: Encapsulating Styles with Shadow DOM and Web Components

- 21.02.26 - ErcanOPAK comment on HTML5: Encapsulating Styles with Shadow DOM and Web Components

Avoid ‘CSS Bleeding’. Shadow DOM allows you to attach a hidden, separate DOM to an element, ensuring its styles don’t leak out and affect the rest of the page. Ideal for: Design systems, widgets, and reusable library components.

Read More
HTML

HTML5: Pro Form Validation without a Single Line of JavaScript

- 21.02.26 - ErcanOPAK comment on HTML5: Pro Form Validation without a Single Line of JavaScript

Native HTML5 validation is faster and more secure than JS-only checks. Combined with the :invalid CSS pseudo-class, you can build a full-featured validation system natively.

Read More
HTML

HTML5: Professional Image Optimization with and WebP

- 21.02.26 - ErcanOPAK comment on HTML5: Professional Image Optimization with and WebP

Don’t serve giant JPEGs to mobile users. Use modern formats with fallbacks. This approach saves up to 70% in bandwidth while ensuring every browser sees the image.

Read More
HTML

HTML5: Stop Using JS Modals – The Native Element is Here

- 21.02.26 - ErcanOPAK comment on HTML5: Stop Using JS Modals – The Native Element is Here

Native modals are better for accessibility and performance. No extra libraries needed. This is a native modal! Close Open Modal

Read More
HTML

HTML5: Use picture Element for Art Direction and Responsive Images

- 21.02.26 - ErcanOPAK comment on HTML5: Use picture Element for Art Direction and Responsive Images

img with srcset changes resolution. picture element lets you change entire image based on screen size. Different Images for Different Screens: <picture> <!– Mobile: Portrait crop –> <source media=”(max-width: 600px)” srcset=”portrait.jpg”> <!– Tablet: Square crop –> <source media=”(max-width: 1024px)” srcset=”square.jpg”> <!– Desktop: Landscape crop –> <img src=”landscape.jpg” alt=”Hero image”> </picture> Modern Format with Fallback: <picture> […]

Read More
HTML

HTML5: Use output Element to Display Calculation Results Instantly

- 17.02.26 - ErcanOPAK comment on HTML5: Use output Element to Display Calculation Results Instantly

Showing form calculation results in a div is hacky. HTML5 output element is semantic and accessible. Basic Example: <form oninput=”result.value = parseInt(a.value) + parseInt(b.value)”> <input type=”number” id=”a” value=”0″> + <input type=”number” id=”b” value=”0″> = <output name=”result” for=”a b”>0</output> </form> Tips Calculator: <form oninput=”tip.value = (bill.value * pct.value / 100).toFixed(2)”> Bill: <input type=”number” id=”bill”> Tip %: […]

Read More
HTML

HTML5: Use meter Element for Visual Progress Indicators

- 16.02.26 - ErcanOPAK comment on HTML5: Use meter Element for Visual Progress Indicators

Creating progress bars with divs and CSS is complex. HTML5 meter shows value ranges natively. Basic Usage: <meter min=”0″ max=”100″ value=”75″>75%</meter> With Optimal Ranges: <meter min=”0″ max=”100″ low=”25″ high=”75″ optimum=”50″ value=”80″> 80% (High) </meter> <!– Browser colors bar automatically: 0-25: Red (low) 25-75: Yellow (medium) 75-100: Green (high) –> Use Cases: – Disk usage – […]

Read More
HTML

HTML5: Use input type=’date’ for Native Date Picker

- 15.02.26 - ErcanOPAK comment on HTML5: Use input type=’date’ for Native Date Picker

JavaScript date picker libraries add 100KB+ overhead. HTML5 date input is native and lightweight. Basic Usage: <input type=”date” name=”birthday” min=”1900-01-01″ max=”2024-12-31″> Features: – Native calendar popup on all browsers – Automatic validation – Mobile-optimized keyboard – Supports min/max constraints – Returns YYYY-MM-DD format Other Useful Types: <input type=”time”> <!– HH:MM picker –> <input type=”datetime-local”> <!– […]

Read More
HTML

HTML5: Use datalist for Autocomplete Input Without JavaScript

- 15.02.26 - ErcanOPAK comment on HTML5: Use datalist for Autocomplete Input Without JavaScript

Building autocomplete manually with JavaScript is complex. Datalist provides native autocomplete. HTML: <input list=”browsers” name=”browser” placeholder=”Choose browser”> <datalist id=”browsers”> <option value=”Chrome”> <option value=”Firefox”> <option value=”Safari”> <option value=”Edge”> <option value=”Opera”> </datalist> User types, browser shows matching suggestions. No JavaScript needed! Features: – Filters as user types – Can still type custom value – Fully accessible – […]

Read More
HTML

HTML5: Use dialog Element for Native Modals Without JavaScript Libraries

- 14.02.26 - ErcanOPAK comment on HTML5: Use dialog Element for Native Modals Without JavaScript Libraries

Bootstrap modals require heavy JavaScript. HTML5 dialog element is native, lightweight, and fully accessible. HTML: <dialog id=”myDialog”> <h2>Modal Title</h2> <p>Modal content here</p> <button onclick=”closeDialog()”>Close</button> </dialog> <button onclick=”openDialog()”>Open Modal</button> JavaScript: function openDialog() { document.getElementById(‘myDialog’).showModal(); } function closeDialog() { document.getElementById(‘myDialog’).close(); } // Close on backdrop click myDialog.addEventListener(‘click’, (e) => { if (e.target === myDialog) myDialog.close(); }); Features: […]

Read More
HTML

HTML5: Use details and summary Tags for Native Accordions

- 13.02.26 - ErcanOPAK comment on HTML5: Use details and summary Tags for Native Accordions

No JavaScript or libraries needed for accordions. HTML5 has native collapsible elements. Basic Accordion: <details> <summary>Click to expand</summary> <p>Hidden content here. Shows when user clicks.</p> </details> Open by Default: <details open> <summary>Already expanded</summary> <p>Content visible on load.</p> </details> Style It: summary { cursor: pointer; font-weight: bold; padding: 10px; background: #f0f0f0; } summary:hover { background: #e0e0e0; […]

Read More
HTML

HTML5: Use loading=’lazy’ Attribute to Defer Offscreen Images

- 13.02.26 - ErcanOPAK comment on HTML5: Use loading=’lazy’ Attribute to Defer Offscreen Images

Images below the fold slowing page load? Native lazy loading defers them until user scrolls. Add One Attribute: <img src=”image.jpg” loading=”lazy” alt=”Description”> Browser only loads image when it’s about to enter viewport. No JavaScript needed! Works on iframes too: <iframe src=”video.html” loading=”lazy”></iframe> Performance: Page with 50 images below fold loads 3x faster. Images load on-demand […]

Read More
HTML

HTML5 Semantic Secret: How Proper Structure Can Boost SEO by 40% Without Extra Content

- 05.02.26 - ErcanOPAK comment on HTML5 Semantic Secret: How Proper Structure Can Boost SEO by 40% Without Extra Content

Writing more content but getting less traffic? Proper semantic HTML structure tells search engines exactly what your page is about. The SEO Problem with Div Soup: My Site Home About Contact Article Title Article content here… Recent Posts ยฉ 2024 Solution: Semantic HTML5 Elements My Awesome Blog Expert tips for developers Home About Contact Search […]

Read More
HTML

HTML5: Use Picture Element for Responsive Images (Better Than srcset)

- 03.02.26 - ErcanOPAK comment on HTML5: Use Picture Element for Responsive Images (Better Than srcset)

Serving same 4K image to mobile users? Picture element lets you serve different images per device, saving 80% bandwidth and loading 3x faster. The Old Way – One Image for All: <img src=”hero-4k.jpg” alt=”Hero” /> <!– Problems: – Mobile downloads 5MB 4K image – Only displays 800px wide on phone – Wasted 80% of bandwidth […]

Read More
HTML

HTML5 Web Workers: Run JavaScript in Background Thread Without Freezing UI

- 01.02.26 - ErcanOPAK comment on HTML5 Web Workers: Run JavaScript in Background Thread Without Freezing UI

Heavy JavaScript computation freezing your webpage? Web Workers run code in a separate thread, keeping your UI responsive. The UI Freezing Problem: // โŒ BAD: Blocks UI for 5 seconds function processLargeData() { const data = Array.from({ length: 10000000 }, (_, i) => i); const result = data .filter(n => n % 2 === 0) […]

Read More
HTML

Use HTML Dialog Element for Accessible Modals (Forget JavaScript Libraries)

- 01.02.26 | 01.02.26 - ErcanOPAK comment on Use HTML Dialog Element for Accessible Modals (Forget JavaScript Libraries)

Still using Bootstrap modals or custom JavaScript? The native <dialog> element handles accessibility, focus trapping, and backdrop clicks automatically. The Complete HTML: <!– The dialog element –> <dialog id=”myModal”> <form method=”dialog”> <h2>Confirm Action</h2> <p>Are you sure you want to delete this item?</p> <div class=”actions”> <button value=”cancel”>Cancel</button> <button value=”confirm” autofocus>Delete</button> </div> </form> </dialog> <!– Trigger button […]

Read More
HTML

The loading=”lazy” Attribute Is Not Just About Images

- 31.01.26 - ErcanOPAK comment on The loading=”lazy” Attribute Is Not Just About Images

Everyone uses it for images.Almost nobody uses it for iframes. Example <iframe src=”https://www.youtube.com/embed/VIDEO_ID” loading=”lazy”> </iframe> Why this matters Prevents layout blocking Improves First Contentful Paint (FCP) Massive win for content-heavy blogs Cause โ†’ Effect Less initial network pressure โ†’ faster perceived load.

Read More
Page 1 of 3
1 2 3 Next ยป

Posts navigation

Older posts
April 2026
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
27282930  
« Mar    

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (950)
  • How to add default value for Entity Framework migrations for DateTime and Bool (859)
  • Get the First and Last Word from a String or Sentence in SQL (836)
  • How to select distinct rows in a datatable in C# (805)
  • How to make theater mode the default for Youtube (754)
  • Add Constraint to SQL Table to ensure email contains @ (578)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (564)
  • Average of all values in a column that are not zero in SQL (531)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (489)
  • Find numbers with more than two decimal places in SQL (448)

Recent Posts

  • C#: Use Init-Only Setters for Immutable Objects After Construction
  • C#: Use Expression-Bodied Members for Concise Single-Line Methods
  • C#: Enable Nullable Reference Types to Eliminate Null Reference Exceptions
  • C#: Use Record Types for Immutable Data Objects
  • SQL: Use CTEs for Readable Complex Queries
  • SQL: Use Window Functions for Advanced Analytical Queries
  • .NET Core: Use Background Services for Long-Running Tasks
  • .NET Core: Use Minimal APIs for Lightweight HTTP Services
  • Git: Use Cherry-Pick to Apply Specific Commits Across Branches
  • Git: Use Interactive Rebase to Clean Up Commit History Before Merge

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (950)
  • How to add default value for Entity Framework migrations for DateTime and Bool (859)
  • Get the First and Last Word from a String or Sentence in SQL (836)
  • How to select distinct rows in a datatable in C# (805)
  • How to make theater mode the default for Youtube (754)

Recent Posts

  • C#: Use Init-Only Setters for Immutable Objects After Construction
  • C#: Use Expression-Bodied Members for Concise Single-Line Methods
  • C#: Enable Nullable Reference Types to Eliminate Null Reference Exceptions
  • C#: Use Record Types for Immutable Data Objects
  • SQL: Use CTEs for Readable Complex Queries

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com