+ 1
When to use the <div> and <article> tags?
When should one use the <div> and <article> tag? What is the difference between using the <div> and <article> tag?
5 Respuestas
+ 9
Ryan Lusby Good answer.
I had to reread your 2nd paragraph to realize you weren't saying the Article tag was meant only for news report or blog posts. 🤦♂️ I need to get some rest. 😜
Simply restated, the Article tag is meant for content that can be independent or stand on its own.
Examples can include:
- blog posts
- news stories
- product details
- product reviews
- user comments
- an article about anything
- answer posted here in SoloLearn
- the main content on an about us page
- a user profile section
- a tweet on a Twitter feed
Hopefully this helps clear up any potential confusion others might have. 😉
+ 6
A div is an empty container and can be used to style different things. You can wrap it around what you need to like multiple paragraphs to apply a style to all of them if you didnt want to style <p> itself.
Article is used to wrap around a news report or a blog post. It is meant to be used on content that is meant to be reusable or that would make sense by itself.
+ 3
David Carroll yes i can see how the way i put it could be confusing since i meant like a blog or news article. Thanks for clarifying!
+ 2
https://www.w3schools.com/html/html5_semantic_elements.asp
A really good article on semantic HTML. Semantic because the tag tells you something about its use and content.
+ 2
We use article tag, if seo is the concern, this is a way to inform search engine the type of content that going to be.
You can use div tag for all your article contents, if seo is not your concerns. There are no difference in term of style and design of the html document between these 2 tags.
Many famous websites do not use article tag at all, since the contents, and other class name clearly indicating the type of articles that can identified easily by search engines.