Stop using div in React (+ Fragment, Semantic Tags)

Поделиться
HTML-код
  • Опубликовано: 3 июн 2024
  • 👉 NEW React & Next.js Course: bytegrad.com/courses/professi...
    Hi, I'm Wesley. I'm a brand ambassador for Kinde (paid sponsorship).
    👉 Add authentication to your app FAST: bit.ly/3QOe1Bh
    👉 NEW React & Next.js Course: bytegrad.com/courses/professi...
    👉 Professional JavaScript Course: bytegrad.com/courses/professi...
    👉 Professional CSS Course: bytegrad.com/courses/professi...
    👉 Discord: all my courses have a private Discord where I actively participate
    🔔 Email newsletter (BIG update soon): email.bytegrad.com
    ⏱️ Timestamps:
    0:00 Intro
    0:08 div problems
    1:13 React Fragment
    1:39 Second example: long vs short
    2:58 Semantic Tags
    3:20 html, head, body
    4:52 main
    5:19 header
    5:53 nav, ul, li, a, Link, img
    7:12 footer
    8:12 section
    9:06 h1, h2, h3
    9:20 p
    9:26 aside
    9:35 article
    10:27 button vs a
    10:46 input vs textarea
    10:52 b, strong, i, em vs span
    11:59 Stripe website
    13:50 MDN website
    14:36 Web apps
    15:32 Important
    #webdevelopment #programming #coding

Комментарии • 127

  • @tnktaliaba2994
    @tnktaliaba2994 9 месяцев назад +82

    It’s really nice to review the basics of semantics directly with reactjs and not in an html file. Thanks!

    • @ByteGrad
      @ByteGrad  9 месяцев назад +6

      Thanks, that was indeed the goal

  • @samuelsamson690
    @samuelsamson690 8 месяцев назад +9

    I love how you go straight to the point cover little things in a very huge way I really appreciate.

  • @Waxaranai
    @Waxaranai 9 месяцев назад +25

    sometimes people forgot to learn the basics, great content!

  • @developedbythet
    @developedbythet 8 месяцев назад +4

    Another educator that use semantic tags properly and it feels satisfied. In a world of modern component based era, people are misusing 'div' everywhere. Thank you.

  • @trusht
    @trusht 9 месяцев назад +7

    I'm now inspired to replace unnecessary div elements throughout my app with more semantic tags. Thanks for the insights!🙏

  • @Adenafun
    @Adenafun 9 месяцев назад +2

    Wow, that was great especially since I liked how fast and straight you talk about everything not jumping around the subject. Thanks a lot ❤

  • @blackpurple9163
    @blackpurple9163 9 месяцев назад +1

    This cleared up a lot of underlying doubts, great information, thanks for making it so easy

  • @core-developers
    @core-developers 9 месяцев назад +4

    I didn't consider the importance of semantic tags until I started using them in schema structures. They make a significant difference in SEO

  • @boneykingofsomewhere
    @boneykingofsomewhere 9 месяцев назад +2

    What a fantastic video! This really taught me much more about the meaning and value of semantics and layouts, you got a subscriber buddy :D

  • @abderrahmanemya6602
    @abderrahmanemya6602 9 месяцев назад +1

    your videos suite my short attention span lol. you talk fast but calmly, and you get straight to the point, i learn a lot in a small amount of time. i would love to connect with you on linkedin

  • @wizard.of.moz.472
    @wizard.of.moz.472 7 месяцев назад +1

    This video was AMAZING! As soon as I started following your advice everything started to click! Please make one explaining forms, etc!

  • @tomich20
    @tomich20 5 месяцев назад +1

    thanks, so many years, and now i understand the diff between article and section 🙌

  • @BladyCzlowiek
    @BladyCzlowiek 9 месяцев назад +4

    this really is the best channel on youtube. The amount of knowledge I gained from this channel. I am looking forward to the nextjs course

    • @ByteGrad
      @ByteGrad  9 месяцев назад

      Thanks, appreciate it

  • @ROL4NDFPV
    @ROL4NDFPV 9 месяцев назад +1

    Nice video good information, one side note a is the same as a unless when you add an title, aria-label or aria-labelledby on the .
    Here's some more info on it
    ---
    A landmark containing content that is relevant to a specific, author-specified purpose and sufficiently important that users will likely want to be able to navigate to the section easily and to have it listed in a summary of the page. Such a page summary could be generated dynamically by a user agent or assistive technology.
    Authors SHOULD limit use of the region role to sections containing content with a purpose that is not accurately described by one of the other landmark roles, such as main, complementary, or navigation.
    Authors MUST give each element with role region a brief label that describes the purpose of the content in the region. Authors SHOULD reference a visible label with aria-labelledby if a visible label is present. Authors SHOULD include the label inside of a heading whenever possible. The heading MAY be an instance of the standard host language heading element or an instance of an element with role heading.
    Assistive technologies SHOULD enable users to quickly navigate to elements with role region. Mainstream user agents MAY enable users to quickly navigate to elements with role region.
    ---
    As found on www.w3.org/TR/wai-aria/#region

  • @LynxBaretta
    @LynxBaretta 9 месяцев назад +1

    I really really like the content of this video a los of things that I was not paying attention and I was still doing like sometimes using divs instead of fragments and correct use of HTML semantics I that I was not aware of their correct meaning. Thanks!

  • @diogosaraiva17
    @diogosaraiva17 9 месяцев назад +7

    As a junior developer I can affirm that this video is gold. Thanks a lot dude + subscribed

    • @pianistanton1
      @pianistanton1 9 месяцев назад

      how long have you been learning front end to get your first job? Is it still possible to get a job as a junior frontend? or everyone just need mid/senior?

    • @diogosaraiva17
      @diogosaraiva17 9 месяцев назад +1

      @pianistanton1 I would say that it's hard to get a job as a junior developer but if you're consistent with your daily code you'll get a job sooner or later. Also, try to create/fix github repos, recruiters often ask for it, at least in europe.

  • @Alex-bc3xe
    @Alex-bc3xe Месяц назад +1

    You are really good teacher.

  • @takeshikriang
    @takeshikriang 9 месяцев назад +1

    Great video. Clear and concise, thanks

  • @manpreetjord1885
    @manpreetjord1885 9 месяцев назад +1

    great work. Covered some really good topics which people generally ignore because it still works for them. Just one thing, I thought I was watching the video on 1.25x but when I checked and it was normal speed.

  • @cmdxen
    @cmdxen 9 месяцев назад +1

    another hidden gem channel 💯, sleek explanation

  • @tszhong0411
    @tszhong0411 9 месяцев назад +2

    Thanks! I learned new things today.

  • @ElliottTheUnicorn
    @ElliottTheUnicorn 8 месяцев назад +1

    learned a lot, subbed

  • @AlexMercadoGo
    @AlexMercadoGo 9 месяцев назад +4

    I wish I wasn’t leaving a Svelte team for a React team

  • @tomasburian6550
    @tomasburian6550 9 месяцев назад +1

    Thanks for the good stuff, learned something new 👍

  • @joantsyn7578
    @joantsyn7578 25 дней назад +1

    Great contents!👍

  • @2gbeh
    @2gbeh 9 месяцев назад +1

    You said it all. I always encourage my studs to use HTML5 with strict XML guidelines 😎👍

  • @ganesha3559
    @ganesha3559 9 месяцев назад +2

    what an exceptional video! Trust me, this is one of a kind.
    Your semantic tag explanation with a real world popular website as a review -- this content cannot be found anywhere in the web
    for this alone you need a Subscribe + Bell icon hit.
    bravo....

    • @ByteGrad
      @ByteGrad  9 месяцев назад

      Thanks, appreciate it

  • @MrPlaiedes
    @MrPlaiedes 8 месяцев назад +3

    As a lead dev, semantics are important for accessibility but eventually you'll likely be building components that are abstracted away from the actual web page. It's still important to minimize div soup.

    • @ByteGrad
      @ByteGrad  8 месяцев назад

      Yep, fair point

  • @yuvalbra
    @yuvalbra 9 месяцев назад +2

    what extensions you used with react and nextjs ?

  • @AWaterKnight
    @AWaterKnight 9 месяцев назад

    You can also return an array of elements, though I do not prefer that, either. I guess being able to pull out articles means that the structural content is meaningful, it does not have the environmental styling or accompanied behavior normally if you just pull out HTML code between opening and closing article tag. A lot of divs are spawned to use them for layouting as said in the video. This way, you can separate the concerns rather than passing the styling information to the contained element and making it their responsibility to correctly apply it.

  • @jonzer3028
    @jonzer3028 9 месяцев назад +1

    Learned a lot, thanks.

  • @gotosleepqueen7959
    @gotosleepqueen7959 9 месяцев назад +2

    I learned a lot from this video!

  • @zush2305
    @zush2305 9 месяцев назад +1

    That's really nice way of covering this topic.
    I had the same idea of diving in into HTML semantics, are there any good resources to read about this that you'd recommend?

  • @tvujtatata
    @tvujtatata 6 месяцев назад

    Good stuff most people dont talk about. Personally, I am more interested in writing semantically correct markup although I am a bit confused when it comes to details. Nav without a Header if there is nothing but navigation in the header. Section in Main, if there is only 1 table and 1 button on the whole page.

  • @sivadhanushuppalapati4041
    @sivadhanushuppalapati4041 8 месяцев назад +2

    This video and the content is too good.

  • @user-ru8hn9hb5c
    @user-ru8hn9hb5c 8 месяцев назад +1

    They didn't teach this in college, lol. Thanks!

  • @AndrewAkaHrun
    @AndrewAkaHrun 9 месяцев назад +1

    Amazing tutorial!

  • @Diego_Cabrera
    @Diego_Cabrera 9 месяцев назад +4

    You should make a video on the folder structure best practices.

    • @ByteGrad
      @ByteGrad  9 месяцев назад +1

      It’s on the todo-list, thanks 👍

  • @abishekbaiju1705
    @abishekbaiju1705 Месяц назад +1

    Thanks a lot

  • @thedelanyo
    @thedelanyo 9 месяцев назад +1

    I guess they called this dividities. And the way first versions of reactjs was it feels natural to wrap everything with div

  • @gurvirbaraich2028
    @gurvirbaraich2028 9 месяцев назад +1

    Great, you learned from the comment on your yesterday's video, but it would be nice if you could speak a bit more loud.

  • @fdkgamer3631
    @fdkgamer3631 9 месяцев назад +1

    Istg overwhelmed by everyone..Some people is saying div is everything..Some is saying don't start with the div..need a complete video on when to use div

  • @ahmednabil4456
    @ahmednabil4456 11 дней назад +1

    thanks

  • @Ogos-End
    @Ogos-End Месяц назад +1

    Your vid has good semantic meaning..

  • @touratica
    @touratica 9 месяцев назад +17

    I really like how informative your videos are, but it sure would be a lot easier to understand you if the sound were a bit louder. That said, keep up with the great content

    • @ByteGrad
      @ByteGrad  9 месяцев назад +1

      Sorry about that, will increase volume

    • @fugduhhh
      @fugduhhh 9 месяцев назад +5

      It's loud enough. Just hit the volume increase button a few times 😒

    • @purshotambohra2131
      @purshotambohra2131 8 месяцев назад

      @@fugduhhh correct

    • @tvujtatata
      @tvujtatata 6 месяцев назад

      @@fugduhhh When you need to do this for every audio content, it becomes annoying. I dont think such a small recommendation hurts anyone. Dont forget about accessibility that the video is also partly about.

  • @holyjack5215
    @holyjack5215 8 месяцев назад

    Here it goes refactoring… Thanks for a great video!

  • @taborgreat
    @taborgreat 9 месяцев назад

    good video. if you let your jaw relax (drop all biting force deep in your molars and cheeks) and use your jaw more while you talk (let it slide side to side and front to back loosely and with energy with each word), it'll really help with your pronunciation.

  • @manmittiwade
    @manmittiwade 9 месяцев назад +1

    Please make tutorial on big project
    your portfolio website is amazing

  • @marcowassink3803
    @marcowassink3803 8 месяцев назад

    How do you get these code suggestions?

  • @philipepics
    @philipepics 9 месяцев назад +1

    is recommended using section with a heading tag, without causes warning

  • @JaGaNezhil
    @JaGaNezhil 9 месяцев назад +1

    Great work❤

  • @gwesa2921
    @gwesa2921 9 месяцев назад +3

    Just a tip. Do not use index from an array method as the unique key identifier, it can cause problems when the list is dynamic, meaning that items can be deleted or added. Some of the problems are: Re-rendering, State preservation and animation problems. Better to use an ID, a slug or a hash.

  • @VadimCherepnin
    @VadimCherepnin 9 месяцев назад

    Which Visual Studio Code theme do you use?

  • @jaycodes8790
    @jaycodes8790 9 месяцев назад +1

    Hey amazing content,
    Could you please make a video on "Modal based routing" in nextjs.
    How one can implement that on a large project. So that i can share a link of a modal directly.

    • @ByteGrad
      @ByteGrad  9 месяцев назад

      Thanks. I actually have that on the todo-list haha, stay tuned

  • @404-not-found-service
    @404-not-found-service 2 месяца назад +1

    woow Thanks

  • @ryostyles9904
    @ryostyles9904 9 месяцев назад

    Is it same as using the empty fragment? (
    Items
    )

  • @kamrulislam3841
    @kamrulislam3841 9 месяцев назад

    very impressive teaching but try to sound louder please

  • @luisllaboj
    @luisllaboj 9 месяцев назад

    What is the keyboard shortcut to import components? Like for "Link" and "Footer" you click on something and they're instantly imported. How can I do that without having to click on the little lightbulb that imports it for me?

    • @ByteGrad
      @ByteGrad  9 месяцев назад

      I use CTRL + Space

    • @luisllaboj
      @luisllaboj 9 месяцев назад

      @@ByteGrad Thank you!

  • @maheshadusumilli7833
    @maheshadusumilli7833 9 месяцев назад

    Hey Bytegrad.
    I tried searching your course in Udemy for CSS. But it is not appearing there while searching. Only with the link it is working. I am able to see only Javascript course. Can you help on how to find your CSS course from Udemy website?

  • @CottidaeSEA
    @CottidaeSEA 9 месяцев назад +1

    This is really not an isolated issue in React. It's everywhere in the frontend world. I've seen many cases where multiple nested divs have been used for simple styling, instead of just putting the classes on the first div.

    • @wchorski
      @wchorski 9 месяцев назад +1

      i'd assume a lot of that is coming from no/low code page builders or CSS frameworks that prioritize modularity over markdown simplicity.

    • @CottidaeSEA
      @CottidaeSEA 9 месяцев назад

      @@wchorski Partially, but a lot of it is just lack of thought, copy-paste, etc.

  • @eistache3182
    @eistache3182 9 месяцев назад +1

    Ok I didn't know that React Fragments can have a key property, I wish I knew this 3 hours ago, literally.

  • @okkaraung9512
    @okkaraung9512 9 месяцев назад +1

    waiting for your React, Nodejs and MERN stack courses on Udemy. Big fan.

    • @ByteGrad
      @ByteGrad  9 месяцев назад

      Thanks, make sure you’re on the email list :)

  • @lel0uchfr199
    @lel0uchfr199 9 месяцев назад

    7:00 for the Link tag you should use to="/" instead of href="/"

    • @jeetgangwar1614
      @jeetgangwar1614 9 месяцев назад +1

      In the react-router-dom's component, the attribute to="/" is used. However, when using the component in Next.js, the attribute href="/" is used instead.

    • @lel0uchfr199
      @lel0uchfr199 9 месяцев назад

      @@jeetgangwar1614 oh never thought about it, thanks for correcting me and understand something I didn’t knew < 3

  • @_abuk
    @_abuk 9 месяцев назад

    Couldnt you also use display:contents?

  • @jinx.love.you.
    @jinx.love.you. 3 месяца назад +1

    And I am that Junior Developer...

  • @prashlovessamosa
    @prashlovessamosa 9 месяцев назад +1

    Hello brother when will you release react course on udemy still waiting already completed JS.

    • @ByteGrad
      @ByteGrad  9 месяцев назад +1

      Soon. It won’t be released on Udemy. Make sure you’re on the email list :)

  • @nabeelali6753
    @nabeelali6753 9 месяцев назад

    All of these are just good-to-know. At work and in production, the hierarchy of importance is:
    1) Functionality
    2) Optimization
    3) Design
    4) "Best" practices aka nerdsht preferences such as these which are actually negligible

  • @harpo187bling
    @harpo187bling 9 месяцев назад +1

    Professional React & Next.js

    • @ByteGrad
      @ByteGrad  9 месяцев назад

      I’m finishing up the details. Make sure you’re on the email list for early-bird pricing 😉

  • @complikatd
    @complikatd 9 месяцев назад

    Your mic sounds grainy for some reason. It seems you're even using a Shure mic too.

  • @sujonpramanik1151
    @sujonpramanik1151 9 месяцев назад +1

    It was awesome

  • @pomawewka
    @pomawewka 8 месяцев назад

    Subheding for SEO as always H tag

  • @Tin9102
    @Tin9102 9 месяцев назад

    according to React docs, you should avoid using index as a key tho.

  • @ck-dl4to
    @ck-dl4to 9 месяцев назад +1

    section + div everywhere

  • @jayakumar9976
    @jayakumar9976 9 месяцев назад +1

    This great.

  • @Ogos-End
    @Ogos-End Месяц назад +1

    This video has good.. semantic meaning...

  • @jerryalmeida
    @jerryalmeida 9 месяцев назад

    Stop using && in React Conditional Rendering, use the ternary operator instead

  • @shariqueansari9439
    @shariqueansari9439 9 месяцев назад +1

    Awesome

  • @abhishekkadam2999
    @abhishekkadam2999 9 месяцев назад

    is division/subdivision for section, etc.
    I don't think it's just for styling.

    • @Burrijw
      @Burrijw 9 месяцев назад

      It serves no semantic purpose and is mostly ignored by screen readers and other assistive tech. The only purpose of a div is to contain other elements for styling, and in some cases, to represent a visual element that cannot otherwise be created with a more semantic element.

  • @tomfancode
    @tomfancode 9 месяцев назад

    Div is good😅
    Sometimes, over engineering

  • @maxterrain
    @maxterrain 8 месяцев назад

    Thank God I'm using Vue. It looks so complex, while vue is just html on steroids.

  • @MageLink
    @MageLink 9 месяцев назад

    I'm going to use many divs as I want

  • @user-ni9tf5yr6m
    @user-ni9tf5yr6m 9 месяцев назад

    = ?

  • @TheNarstonerz
    @TheNarstonerz 8 месяцев назад

    No !

  • @robertbutcher222
    @robertbutcher222 9 месяцев назад

    About the button layout example, why do you even need a fragment? Couldn’t you just straight away map over the buttons inside the section?

    • @ByteGrad
      @ByteGrad  9 месяцев назад

      Fragment is still necessary because there will be a span as well for the first one (always need to return 1 React node)

  • @user-dh9rh3js3u
    @user-dh9rh3js3u 9 месяцев назад +1

    Are you a robot | alien ?

    • @ByteGrad
      @ByteGrad  9 месяцев назад

      🤣

    • @user-dh9rh3js3u
      @user-dh9rh3js3u 9 месяцев назад

      @@ByteGrad Yes Sir, I really struggled to find out a single expression on your face. seems like you are just reading news like an anchor person

  • @adventureswithpasa
    @adventureswithpasa 9 месяцев назад

    Stop using section, article always use div.

  • @metaxx5253
    @metaxx5253 9 месяцев назад

    Div or die

  • @francismori7
    @francismori7 9 месяцев назад +1

    HTML cluttering is not an argument. The rendered code is for the browser, not for the developer.

    • @ByteGrad
      @ByteGrad  9 месяцев назад

      We often want to inspect HTML in the inspector tool

  • @Code_express
    @Code_express 9 месяцев назад +1

    speak slowly and speak loudly so we can understand what are you saying

  • @mac.ignacio
    @mac.ignacio 9 месяцев назад

    I say just stops using React and use other framework that has better DX.

  • @mikeonthebox
    @mikeonthebox 9 месяцев назад

    I love how React developers always blame this on "Junior" Developers. How about using a better framework that doesn't force you to return just 1 node leading to this "mistakes"
    And talking about mistakes, aren't you doing a mistake by using index as a key value? I believe React doesn't recommend that at all, and even mentions it can lead to weird behaviors.

  • @acegodas7852
    @acegodas7852 9 месяцев назад

    i dont know are you just for real or just joking?

  • @OpenDeepLearning
    @OpenDeepLearning 9 месяцев назад

    You stopped just when your channel started booming. Why is that?

    • @ByteGrad
      @ByteGrad  9 месяцев назад

      I didn’t stop, more to come soon :)

    • @OpenDeepLearning
      @OpenDeepLearning 9 месяцев назад

      @@ByteGrad ok, great!

  • @flamme8587
    @flamme8587 9 месяцев назад

    Excuse me but, why you didn't show the empty element that works perfectly fine to wrap elements in a empty body instead of React.Fragment " "

  • @MatthewKennedyUK
    @MatthewKennedyUK 9 месяцев назад

    Better idea… stop using react.

  • @yogeshkadu5453
    @yogeshkadu5453 9 месяцев назад +1

  • @randerins
    @randerins 9 месяцев назад +1

    k, I'll start using instead