Lädt...


🔧 Semantic HTML Elements vs the DIV


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

So lately, I started to take a Front End Web Development class because I wanted to go over and review basic concepts and also fill in any knowledge gaps that I may have. While taking this class I came across something that we are all very familiar with but I believe that maybe with work within our different tech stacks or focus on Javascript, we are losing sight of more and more.

I remember when I first learned about HTML elements when I was in high school during the 1990's. Yes we actually had computers back then and many of us already had the internet in our house. In my high school, this had to be around 1998 or so, we really had a basic HTML class. We of course talked a bit about styling, but there wasn't any discussion about separate style sheets, and we didn't even touch javascript.

I remember writing my first HTML tags and I thought they were really interesting how with only text I could change the way something looks. If you're reading this, I don't need to tell you how conventions over the decades have changed but also habits have changed as well.

For those that don't know, semantic HTML elements are descriptive and really work to help both the developer and the browser to layout the website in a very clear and coherent way. The very basic form of this is as follows:

<html>
  <head>
    <title></title>
  </head>
  <body>
    <h1></h1>
    <p></p>
    <h2></h2>
    <p></p>
  </body>
</html>

Really there is more that I could put in the example but this is simple, it's easy for another developer to read and you know very easily what goes where and what everything will look like. Writing semantic HTML is also great for accessibility, such as things like screen readers, etc.

At the same time, habits change and I wonder how much a focus towards Javascript libraries and frameworks has destroyed the practice of using semantic HTML. Typical non-semantic HTML instead of using different tags for each element, is just full of div elements. A typical piece of non-semantic HTML may look something like this:

<div id="header"></div>
<div class="section">
    <div class="article">
        <div class="figure">
            <img>
            <div class="figcaption"></div>
        </div>
    </div>
</div>
<div id="footer"></div>

Source (freecodecamp.org)

Any developer with experience of course will tell you that this code is more difficult to read, many times it's harder to follow the developer's logic, and it is not very accessible at all. So why do we write our HTML in this way, including myself? I am just as guilty of this. This is faster and doesn't necessarily need as much thought maybe, but I think many of the frameworks and libraries really encourage people to write this way.

I'm not saying that we shouldn't use those resources, on the contrary, they are indispensable. I know that there will be some Vue or maybe Angular developer who will say that they don't have this problem at all, and maybe they are right.

I develop with React and of course you don't always have to use the

but it's definitely the default and it is encouraged many times for the sake of convenience. I really don't have any solutions to this problem and I know that this is a problem that has been talked about ad nauseum in many different forums, but if there are people that are smarter than me, and I know that there are mountains of you out there, let's talk about this. Let's try to push for a way that we can have the functionality that we crave but also keeping order with what we write.

freeCodeCamp.org. (2021, April 28). Semantic HTML5 elements explained. freeCodeCamp.org. Retrieved March 31, 2023, from https://www.freecodecamp.org/news/semantic-html5-elements/

...

🔧 Semantic elements, Semantic elements in HTML, HTML style guide and declaring document types


📈 66.6 Punkte
🔧 Programmierung

🔧 Semantic HTML Elements vs the DIV


📈 53.54 Punkte
🔧 Programmierung

🐧 div in HTML: Alles Wichtige zur Verwendung des div-Containers


📈 45.11 Punkte
🐧 Server

🔧 How to Make Parent Div Activate Styling of Child Div for Hover and Active States


📈 40.47 Punkte
🔧 Programmierung

🔧 HTML layout elements and techniques, HTML responsive web designs, HTML computer code elements


📈 39.63 Punkte
🔧 Programmierung

🔧 Tìm Hiểu Về RAG: Công Nghệ Đột Phá Đang "Làm Mưa Làm Gió" Trong Thế Giới Chatbot


📈 39.48 Punkte
🔧 Programmierung

🔧 Semantic Elements in HTML


📈 33.3 Punkte
🔧 Programmierung

🔧 HTML Semantic Elements(A to Z)


📈 33.3 Punkte
🔧 Programmierung

🔧 🔥 HTML5 Semantic Elements: Unleash the Power of Meaningful Markup 🔥


📈 28.66 Punkte
🔧 Programmierung

🔧 Make all Array elements equal by replacing it with adjacent elements


📈 25.7 Punkte
🔧 Programmierung

🔧 Find Z for adding K elements of A to match K elements of B


📈 25.7 Punkte
🔧 Programmierung

🔧 Check if set of first X elements of one Array is same as set of first Y elements of other


📈 25.7 Punkte
🔧 Programmierung

📰 Adobe Photoshop Elements und Premiere Elements 2023 veröffentlicht


📈 25.7 Punkte
📰 IT Nachrichten

📰 What’s New in Adobe Photoshop Elements 2021 and Premiere Elements 2021


📈 25.7 Punkte
📰 IT Security Nachrichten

🪟 Adobe Photoshop Elements 2021 and Premiere Elements 2021 released today


📈 25.7 Punkte
🪟 Windows Tipps

🪟 Learn what's new in Adobe Photoshop Elements and Premiere Elements 2021


📈 25.7 Punkte
🪟 Windows Tipps

📰 Photoshop Elements und Premiere Elements 2020: Neue Versionen der Budget-Tools verfügbar


📈 25.7 Punkte
📰 IT Nachrichten

📰 Adobe bringt Photoshop Elements 2020 und Premiere Elements 2020


📈 25.7 Punkte
📰 IT Nachrichten

🪟 Photoshop Elements 2020 and Premiere Elements 2020 now available


📈 25.7 Punkte
🪟 Windows Tipps

📰 Photoshop Elements 15 und Premiere Elements 15 mit neuen Assistenten


📈 25.7 Punkte
📰 IT Nachrichten

📰 Photoshop Elements 15 und Premiere Elements 15 mit neuen Assistenten


📈 25.7 Punkte
📰 IT Nachrichten

💾 Elements+ für Adobe Photoshop Elements 2024 Englisch


📈 25.7 Punkte
💾 Downloads

🔧 Make elements of Array equal by repeatedly dividing elements by 2 or 3


📈 25.7 Punkte
🔧 Programmierung

🔧 How to center a Div in HTML and CSS?


📈 24.88 Punkte
🔧 Programmierung

🔧 TidyCoder day night loading only css/HTML, and single div


📈 24.88 Punkte
🔧 Programmierung

🔧 Ditch the div Tag: Use These HTML Tags Instead


📈 24.88 Punkte
🔧 Programmierung

🔧 HTML file path and HTML head elements


📈 22.14 Punkte
🔧 Programmierung

🔧 Understanding Semantic HTML: A Guide for Developers


📈 20.45 Punkte
🔧 Programmierung

🔧 The importance of semantic HTML for SEO and accessibility.


📈 20.45 Punkte
🔧 Programmierung

🔧 The Importance of Semantic HTML for SEO and Accessibility


📈 20.45 Punkte
🔧 Programmierung

🔧 Day 6: Introduction to Semantic HTML


📈 20.45 Punkte
🔧 Programmierung

🔧 Unlocking the Power of Semantic HTML: Building Meaningful Web Content


📈 20.45 Punkte
🔧 Programmierung

matomo