HTML: how to properly set header for nesting <article> - html

I'm creating a React component which represents a product card. Each product card has a title and a list of sub-product cards, and so on. This nested structure can go infinitively.
At this stage my focus is on having a correct structure, outline and utilizing semantic HTML.
According to MDN, <article> is a correct element to represent this. So I've come up with this structure:
<h1> Products </h1>
<article>
<header>
<h2> Title: Product A </h2>
</header>
<div>
<span>Sub-products:</span>
<ul>
<li>
<article>
<header>
<h2> Title: Product A-1 </h2>
</header>
<div>
<span>Sub-products:</span>
<ul>
<li>
<article>
<header>
<h2> Title: Product A-1-1 </h2>
</header>
</article>
</li>
</ul>
</div>
</article>
</li>
<li>
<article>
<header>
<h2> Title: Product A-2 </h2>
</header>
</article>
</li>
</ul>
</div>
</article>
Now, I'm wondering if using h2 correct at all. I was thinking about using h3-h6 but what actually stopped me was that after 6 level of nesting, I wouldn't have a proper tag to use.
So, what's the correct way to present titles as the heading of the articles?

If you nest contents using <article>, use <h1> for the title of each article: Right -- more than one <h1> in the code for one HTML page.
Bruce Lawson wrote a comprehensive article about this subject:
https://www.smashingmagazine.com/2020/01/html5-article-section/
<h1> Products </h1>
<article>
<header>
<h1> Title: Product A </h1>
</header>
<div>
<span>Sub-products:</span>
<ul>
<li>
<article>
<header>
<h1> Title: Product A-1 </h1>
</header>
<div>
<span>Sub-products:</span>
<ul>
<li>
<article>
<header>
<h1> Title: Product A-1-1 </h1>
</header>
</article>
</li>
</ul>
</div>
</article>
</li>
<li>
<article>
<header>
<h1> Title: Product A-2 </h1>
</header>
</article>
</li>
</ul>
</div>
</article>
That said, my preferred approach is actually use aria-labelledBy to connect those <h1>s as the title of each segment, i.e.:
<h1> Products </h1>
<article aria-labelledBy="title001">
<header>
<h1 id="title001"> Title: Product A </h1>
</header>
<div>
<span>Sub-products:</span>
<ul>
<li>
<article aria-labelledBy="title002">
<header>
<h1 id="title002"> Title: Product A-1 </h1>
</header>
<div>
<span>Sub-products:</span>
<ul>
<li>
<article aria-labelledBy="title003">
<header>
<h1 id="title003"> Title: Product A-1-1 </h1>
</header>
</article>
</li>
</ul>
</div>
</article>
</li>
<li>
<article aria-labelledBy="title004">
<header>
<h1 id="title004"> Title: Product A-2 </h1>
</header>
</article>
</li>
</ul>
</div>
</article>
Arguably it's a little elaborative, but creates unmistakable link between each piece of content and its title when accessed with accessible technologies -- even when the segment is tab-navigated into with no chance to read its <h1> element.

Related

Anchor link not working when using unordered list

I wrote an HTML document with seven anchor links to jump to different section on the page. However, only the first and the last links are working and the rest are not working. I cloned the first section which is working alright and then changed the id to the second section. And that made the second anchor link working. So, I know that somewhere in my second to the second last section is not working. However, I cannot find where is wrong. My code passed the w3.org's validator. Could someone look into my code to see what is the problem. I'm still a beginner so please go easy on me. Thank you.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Jade Ichinose Resume</title>
</head>
<body>
<h1>Jade</h1>
<span id="email">Email:</span>
<span id="phone">Mobile:</span>
My LinkedIn Profile
<section>
<h3>Overview</h3>
<ul>
<!-- Link to every section in the page -->
<li>Personal Summary</li>
<li>Education</li>
<li>Skillset</li>
<li>Working Experience</li>
<li>Voluntary Experience</li>
<li>Hobbies and Interests</li>
<li>Referees</li>
</ul>
</section>
<section id="personal_summary">
<h2>Personal Summary</h2>
<p>
describing myself what I studied experience job, volunteering Career goal -> What I want to achieve for the company using my skills and experience
</p>
</section>
<section id=“education”>
<h2>Education</h2>
<ul>
<li>date (start mmm/yy - completed mmm/yy) school</li>
<li>major</li>
<li>Achievement — what I did well in the study —
<ul>
<li>computer programming with the result A+
<ul>
<li> languages and field, courses</li>
</ul>
</li>
</ul>
</li>
</ul>
</section>
<section id=“skillset”>
<h2>Skillset</h2>
<ul>
<li>Hard skills— languages, maths, software, SublimeText3, Wing, Geany, Spyder</li>
<li>Soft skills, English, Japanese, fundamental level Chinese(mandarin), team-orientated, time management,</li>
</ul>
</section>
<section id=“working_experience”>
<h2>Working Experience</h2>
<ul>
<li>date (start mmm/yy - completed mmm/yy) company </li>
<li>role, position</li>
<li>Achievement — what I did well in the job —
<ul>
<li>example1
<ul>
<li> detail about example1 may not be required</li>
</ul>
</li>
</ul>
</li>
</ul>
</section>
<section id=“voluntary_experiene”>
<h2>Voluntary Experience</h2>
<ul>
<li>date (start mmm/yy - completed mmm/yy) company or organisation (church)</li>
<li>role, position</li>
<li>Achievement — what I did well in the job —
<ul>
<li>example1
<ul>
<li> detail about example1 may not be required</li>
</ul>
</li>
</ul>
</li>
</ul>
</section>
<section id=“hobbies_interests”>
<h2>Hobbies and Interests</h2>
<ul>
<li>Cooking</li>
<li>Minerals and Lapidary</li>
</ul>
</section>
<section id="referees">
<h2>Referees</h2>
<ul>
<li>name of the referee, position, company, contact detail (email or phone number)</li>
<li>referee 2</li>
<li>referee 3</li>
</ul>
</section>
</body>
</html>
Take a close look on your ".
<section id=“education”>
<section id="education">
The first is not working, the second does work. You are using a 'right double quotation mark' (”) and not a 'normal quotation mark' (") in the other sections. The first section personal_summary is fine.
The quotation marks that you have used for id are wrong
Use
<section id="education">
Instead of
<section id=“education”>
Same for all other non-working sections
You made a tiny mistake on the type of quotation mark you used.The first and the last are fine and you've used ".." but on the rest you've made the mistake of using “...”. For example for education, you had it as: section id=“education” Instead of:section id="education"
You've also named an ID as id=“voluntary_experiene” and called it using:href="#voluntary_experience" which has a slight spelling mistake. The code below has all the fixed/working anchor tags.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Jade Ichinose Resume</title>
</head>
<body>
<h1>Jade</h1>
<span id="email">Email:</span>
<span id="phone">Mobile:</span>
My LinkedIn Profile
<section>
<h3>Overview</h3>
<ul>
<!-- Link to every section in the page -->
<li>Personal Summary</li>
<li>Education</li>
<li>Skillset</li>
<li>Working Experience</li>
<li>Voluntary Experience</li>
<li>Hobbies and Interests</li>
<li>Referees</li>
</ul>
</section>
<section id="personal_summary">
<h2>Personal Summary</h2>
<p>
describing myself
what I studied
experience job, volunteering
Career goal -> What I want to achieve for the company using my skills and experience
</p>
</section>
<section id="education">
<h2>Education</h2>
<ul>
<li>date (start mmm/yy - completed mmm/yy) school</li>
<li>major</li>
<li>Achievement — what I did well in the study —
<ul>
<li>computer programming with the result A+
<ul>
<li> languages and field, courses</li>
</ul>
</li>
</ul>
</li>
</ul>
</section>
<section id="skillset">
<h2>Skillset</h2>
<ul>
<li>Hard skills— languages, maths, software, SublimeText3, Wing, Geany, Spyder</li>
<li>Soft skills, English, Japanese, fundamental level Chinese(mandarin), team-orientated, time management,</li>
</ul>
</section>
<section id="working_experience">
<h2>Working Experience</h2>
<ul>
<li>date (start mmm/yy - completed mmm/yy) company </li>
<li>role, position</li>
<li>Achievement — what I did well in the job —
<ul>
<li>example1
<ul>
<li> detail about example1 may not be required</li>
</ul>
</li>
</ul>
</li>
</ul>
</section>
<section id="voluntary_experience">
<h2>Voluntary Experience</h2>
<ul>
<li>date (start mmm/yy - completed mmm/yy) company or organisation (church)</li>
<li>role, position</li>
<li>Achievement — what I did well in the job —
<ul>
<li>example1
<ul>
<li> detail about example1 may not be required</li>
</ul>
</li>
</ul>
</li>
</ul>
</section>
<section id="hobbies_interests">
<h2>Hobbies and Interests</h2>
<ul>
<li>Cooking</li>
<li>Minerals and Lapidary</li>
</ul>
</section>
<section id="referees">
<h2>Referees</h2>
<ul>
<li>name of the referee, position, company, contact detail (email or phone number)</li>
<li>referee 2</li>
<li>referee 3</li>
</ul>
</section>
</body>
</html>

In Brackets my end </body> is red, what seems to be the causing this? What is left opened?

<a href="Services.html">
<button type="button"class="btn">Book Now!</button>
<div id="contact">
<p> <b> Contact us: </b> CapitalExplorers#Wellington.com</p>
</div>
</body>
Trying to find out what is causing the </body> to be red. I believe it has something to do with the <a href part but not sure. Any ideas on a potential fix?
Remember to close your tag:
<head>
...
</head>
You're missing the closing tag of the first list.
<body>
<ul id="navigation">
<li>FAQ</li>
<li>Bookings</li>
<li> Services </li>
<li>Home</li>
</ul> <!-- Include here a closing tag -->
The <a> tag also needs to be closed.
<a href="Services.html">
<button type="button"class="btn">Book Now!</button>
</a> <!-- For example, if you want the link only in the button (even if it is not a good practice) -->
<div id="contact">
<p><b>Contact us:</b> CapitalExplorers#Wellington.com</p>
</div>
</body>
looking at the provided snippet. i think this is what your html should look like. added some closing tags and removed some spaces.
<!DOCTYPE html>
<html>
<head>
<title>Capital Explorers- Home</title>
<link rel="stylesheet" type="text/css" href="style.css">
<link href="https://fonts.googleapis.com/css2?family=Arvo:wght#700&family=Chelsea+Market&family=IBM+Plex+Sans:wght#400;600&family=Lato:wght#300&family=Roboto&display=swap" rel="stylesheet">
</head>
<body>
<ul id="navigation">
<li>FAQ</li>
<li>Bookings</li>
<li> Services </li>
<li>Home</li>
</ul>
<h1>Capital <span> Explorers </span></h1>
<div id="header">
<h2>Explore Wellington.</h2>
</div>
<div id="paragraph">
<p> At Capital Explorers, our mission is to provide Fun, Adventurous and <span> Eco-friendly </span> Tours of Wellington City and beyond.
</p>
</div>
<div id="SubPara">
<p> <b>- Maori</b> culture and history, Te Papa, The Cable Car and many more!
<br>
<b>- Travel on</b> foot, with scooters or bicycles, and also electric vehicles.
<br>
<b> - Family </b> owned and operated, with over 15 years of experience in the tourism industry.
<button type="button"class="btn">Book Now!</button>
</div>
<div id="contact">
<p> <b> Contact us:</b> CapitalExplorers#Wellington.com</p>
</div>
</body>
</html>

<a href> on whole page instead of inside <nav>

I tried making menu with 4 links but one of them can be clicked anywhere on the whole page. I tried looking for unclosed tags but can't seem to find anything. I also tried to use sites that check for code errors and they say that there is unclosed tag but either I'm blind or there are no unclosed tags... :/
I know it's noob question but I'm trying for 20 minutes now to find the unclosed tag? that I can't find.
Edit: about.html opens if I click anywhere on the page
I don't know how to upload files so I'm just pasting code below (I also have some css code but I don't think that CSS is the issue):
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="utf-8" />
<meta name="description" content="opis strony" />
<link href="https://fonts.googleapis.com/css?family=Patrick+Hand&subset=latin-ext" rel="stylesheet">
<link rel="stylesheet" href="Style.css">
<title> Kurs HTML i CSS3</title>
</head>
<body>
<div class="container">
<header>
<div class="title">
<h1>Kurs HTML5 i CSS3</h1>
</div>
<nav>
<ul>
<li><a href="index.html">Start</li>
<li><a href="html5.html">HTML5</li>
<li><a href="css3.html">CSS3</li>
<li><a href="about.html">O mnie</li>
</ul>
</nav>
</header>
<div class="content">
<div class="main-content">
<section>
<article id="html5">
<h2>Artykuł o HTML5</h2>
<figure>
<img src="html5.png">
<figcaption>Logo HTML5</figcaption>
</figure>
<p>Witaj na mojej stronie poświęconej HTML5 i CSS3</p>
</article>
<article id="css3">
<h2>Artykuł o CSS3</h2>
<figure>
<img src="css3.png">
<figcaption>Logo CSS3</figcaption>
</figure>
<p>
Przykładowa treść 1 <br>
Przykładowa treść 2
</p>
</article>
</section>
</div>
<div class="sidebar">
<aside>
<h2>JavaScript</h2>
<p>Warto wiedzieć, że do tworzenia stron internetowych często wykorzystuje się również język JavaScript.
Pozwala on na zaprojektowanie interaktywnych stron internetowych poprzez reagowanie na zdarzenia.</p>
</aside>
</div>
</div>
<footer>Wszelkie prawa zastrzeżone &copy</footer>
</div>
</body>
The problem is here:
<nav>
<ul>
<li><a href="index.html">Start</li>
<li><a href="html5.html">HTML5</li>
<li><a href="css3.html">CSS3</li>
<li><a href="about.html">O mnie</li>
</ul>
</nav>
You should close the element after the text of link in this way:
<nav>
<ul>
<li>Start</li>
<li>HTML5</li>
<li>CSS3</li>
<li>O mnie</li>
</ul>
</nav>
If you don't close it everything that comes after the a element is "inside" the anchor element

Overlapping sections, the content of section goes beyond this section

I have problem: first section - header is attachment fixed, and when I reduce the browser window, the background only covers a small portion of the section, the rest of the content is under another section, or completely out of the background. As you will see, only opening this page to the full screen resolves the problem and the sections look correct. By contrast, reducing the window causes the section to fall apart and jump one over the other. Can the cause be lack of clearfixes, or the problem is due to lack of positioning of each section?
https://codepen.io/tubaris/pen/YQQewB/
`<html lang="pl">
<head>
<meta charset="UTF-8">
<meta name="description" content="Omnifood">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Omnifood</title>
<link rel="stylesheet" type="text/css" href="vendors/css/style.css">
<link rel="stylesheet" type="text/css" href="vendors/css/ionicons.min.css">
<link href="https://fonts.googleapis.com/css?family=Lato:100,300,400&subset=latin-ext" rel="stylesheet">
</head>
<body>
<header>
<nav>
<div class="row">
<img src="https://image.ibb.co/bY2jyQ/logo_white.png" alt="Omnifood logo" class="logo">
<ul class="main-nav">
<li>Food delivery</li>
<li>How it works</li>
<li>Our cities</li>
<li>Sign up</li>
</ul>
</div>
</nav>
<div class="header-text-box">
<h1>Goodbye junk food.<br>Hello super healthy meals.</h1>
I’m hungry
Show me more
</div>
</header>
<section class="section-features">
<div class="row">
<h2>Get food fast – not fast food.</h2>
<p class="text-about">Hello, we're Omnifood, your new premium food delivery service. We know you're always busy. No time for cooking. So let us take care of that, we're really good at it, we promise!</p>
</div>
<div class="row">
<div class="feature-col">
<i class="ion-clock icon-big"></i>
<h3>Up to 365 days/year</h3>
<p>Never cook again! We really mean that. Our subscription plans include up to 365 days/year coverage. You can also choose to order more flexibly if that's your style.</p>
</div>
<div class="feature-col">
<i class="ion-jet icon-big"></i>
<h3>Ready in 20 minutes</h3>
<p>You're only twenty minutes away from your delicious and super healthy meals delivered right to your home. We work with the best chefs in each town to ensure that you're 100% happy.</p>
</div>
<div class="feature-col">
<i class="ion-ios-nutrition icon-big"></i>
<h3>100% Organic</h3>
<p>All our vegetables are fresh, organic and local. Animals are raised without added hormones or antibiotics. Good for your health, the environment, and it also tastes better!</p>
</div>
<div class="feature-col">
<i class="ion-card icon-big"></i>
<h3>Order anything</h3>
<p>We don't limit your creativity, which means you can order whatever you feel like. You can also choose from our menu containing over 100 delicious meals. It's up to you!</p>
</div>
</div>
</section>
<section class="section-meals">
<div class="row">
<h2>Omnifood meals showcase</h2>
<p class="text-about">Selected Omnifood meals offered by our company</p>
</div>
<ul class="meals-showcase">
<li>
<figure class="meal-photo">
<img src="https://preview.ibb.co/eTtwCk/1.jpg" alt="egg with vegetables">
</figure>
</li>
<li>
<figure class="meal-photo">
<img src="https://image.ibb.co/iFpgdQ/2.jpg" alt="california rolls sushi">
</figure>
</li>
<li>
<figure class="meal-photo">
<img src="https://preview.ibb.co/igwGCk/3.jpg" alt="asparagus with carrots and meat">
</figure>
</li>
<li>
<figure class="meal-photo">
<img src="https://preview.ibb.co/h74sk5/4.jpg" alt="carrot soup with nuts">
</figure>
</li>
</ul>
<ul class="meals-showcase">
<li>
<figure class="meal-photo">
<img src="https://preview.ibb.co/j4MuyQ/5.jpg" alt="steak with green beans">
</figure>
</li>
<li>
<figure class="meal-photo">
<img src="https://image.ibb.co/m8twCk/6.jpg" alt="roll with egg, rucola and radish">
</figure>
</li>
<li>
<figure class="meal-photo">
<img src="https://preview.ibb.co/bBjEyQ/7.jpg" alt="healthy burger">
</figure>
</li>
<li>
<figure class="meal-photo">
<img src="https://preview.ibb.co/fNWisk/8.jpg" alt="oatmeal with strawberries and cherries">
</figure>
</li>
</ul>
</section>
<section class="section-steps">
<div class="row">
<h2>How it works – Simple as 1, 2, 3</h2>
</div>
<div class="row">
<div class="steps-col1">
<img src="https://image.ibb.co/hHoeXk/app_i_Phone.png" alt="Omnifood app on iPhone" class="app-screen">
</div>
<div class="steps-col2">
<div class="works-step">
<div>1</div>
<p>Choose the subscription plan that best fits your needs and sign up today.</p>
</div>
<div class="works-step">
<div>2</div>
<p>Order your delicious meal using our mobile app or website. Or you can even call us!</p>
</div>
<div class="works-step">
<div>3</div>
<p>Enjoy your meal after less than 20 minutes. See you the next time!</p>
</div>
<img src="https://image.ibb.co/gyPxJQ/download_app.png" alt="app store button">
<img src="https://image.ibb.co/jZWYsk/download_app_android.png" alt="play store button">
</div>
</div>
</section>
</body>
`
I assume what you are asking is why your .features-col div's are cut off.
The reason is, the .features-col divs are taken out of the main flow of the document and are not expanding .section-features div. This is due to the float: left property. When you remove that property, you can instantly see that those columns expand the parent div.
Another way to have the columns aligned to the left side of the page is to have the .row class set to 100% of the window width, then set text-align: left.
Make the .meal-photo class float left.
i.e add float:left to the .meal-photo class in your CSS code.

Part of my HTML is not displaying in Chrome

The top third of my page, including a graphic and headline, shows up just fine in Firefox and Explorer, but does not appear in Chrome when accessed from my server. It does appear in Chrome when viewing the page as a file.
The graphic is defined in the CSS file as:
/** adbox **/
#adbox {
background: #020a13 url(../images/bg-adbox.jpg) no-repeat center top;
font-family: Georgia, "Times New Roman", Times, serif;
min-height: 433px;
margin: -56px 0 22px;
And the HTML file is:
<!DOCTYPE html>
<!-- Website template by freewebsitetemplates.com -->
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>donfiler.net - web design </title>
<link rel="stylesheet" href="css/style.css" type="text/css">
</head>
<body>
<div id="header">
<div class="wrapper clearfix">
<div id="logo">
<img src="images/logo.png" alt="LOGO">
</div>
<ul id="navigation">
<li class="selected">
Home
</li>
<li>
About
</li>
<li>
Blog
</li>
<li>
Gallery
</li>
<li>
Contact Us
</li>
</ul>
</div>
</div>
<div id="contents">
<div id="adbox">
<div class="wrapper clearfix"><p></p><p></p>
<div class="info">
<h1>Web Design & Social Media Marketing</h1>
<p>
Proven Consultant, Author | Helping Companies Translate Their Business Goals to Reality.
</p>
</div>
</div>
<div class="highlight">
<h2>707-217-8457 if you want a mobile friendly web site.</h2>
</div>
</div>
<div class="body clearfix">
<div class="click-here">
<h1>Impact Marketing</h1>
Click Here!
</div>
<p style="font-size:12px;">
Proven Consultant, Author | Helping Companies Translate Their Business Goals to Reality. We design web sites with dynamic database interaction; deliver computer based training; create comprehensive marketing campaigns; specialize in hand coding HTML, CSS, PHP, Mysql and JavaScript to customize web design and user interface.
</p>
</div>
</div>
<div id="footer">
<ul id="featured" class="wrapper clearfix">
<li>
<img src="images/THUMBNAIL_IMAGE4.jpg" alt="Img" height="204" width="180">
<h3>Order Now</h3>
<p>
Memories of growing up in Europe during the Cold War. The first book in a series about Don's life.
</p>
</li>
<li>
<img src="images/THUMBNAIL_IMAGE3.jpg" alt="Img" height="204" width="180">
<h3>Order Now</h3>
<p>
A catchy tune by the Beach Boys in the mid-sixties, the lyrics of "Be True to Your School" hit many highlights of high school in that era.
</p>
</li>
<li>
<img src="images/THUMBNAIL_IMAGE2.jpg" alt="Img" height="204" width="180">
<h3>Order Now</h3>
<p>
College Years and Rock Band Entrepreneur. The third book in a series about Don's life.
</p>
</li>
<li>
<img src="images/THUMBNAIL_IMAGE1.jpg" alt="Img" height="204" width="180">
<h3>Order Now</h3>
<p>
Contributing to others is the highest form of success you can achieve and I wanted to impart what I have learned over the years working for a living.
</p>
</li>
</ul>
<div class="body">
<div class="wrapper clearfix">
<div id="links">
<div>
<h4>Social</h4>
<ul>
<li>
Google +
</li>
<li>
Facebook
</li>
<li>
Youtube
</li>
</ul>
</div>
<div>
<h4>Blogs</h4>
<ul>
<li>
Blogspot
</li>
<li>
Marketing Blog
</li>
<li>
Web Design Blog
</li>
</ul>
</div>
</div>
<div id="newsletter">
<h4>Newsletter</h4>
<p>
Sign up for Our Newsletter
</p>
<form action="https://donfiler.us/newsletter" method="post">
<!--<input type="text" value="">-->
<input type="submit" value="Sign Up!">
</form>
</div>
<p class="footnote">
© Copyright © 2016 Don Filer all rights reserved.
</p>
</div>
</div>
</div>
</body>
</html>
The Google Chrome extension AdBlock is blocking that element for me, because its ID is adbox. Check if you have that extension enabled, as well.
In general, try avoiding the word "ad" when naming HTML elements.
From the start, I can see a major flaw in the code- you named an element adbox. Most ad-blocking extensions work this way- they scan for ads, and that element will be perceived as an ad, simply because of it's name.
To quote CapitalQ,
In general, try avoiding the word "ad" when naming HTML elements.
Check if you have an ad-blocking extension turned on, and if so, try the site without that extension. Also, rename that element ASAP!