I'm building a website using HTML 5 markup, but have hit a problem regarding where to place the the NAV element - because I'm using a SPRY 'Tabbed Panel' for both the navigation and the content:
<header>
<div id="TabbedPanels1" class="TabbedPanels">
<ul class="TabbedPanelsTabGroup">
<li class="TabbedPanelsTab" tabindex="0">Home</li>
<li class="TabbedPanelsTab" tabindex="0">Profile/li>
<li class="TabbedPanelsTab" tabindex="0">Contact</li>
</ul>
<div class="TabbedPanelsContentGroup">
<div class="TabbedPanelsContent">Content 1</div>
<div class="TabbedPanelsContent">Content 2</div>
<div class="TabbedPanelsContent">Content 3</div>
</div>
</div>
I thought the best place to insert the NAV element would be by wrapping the UL element, but this breaks the SPRY Tabbed panel (maybe I can just fix this by changing some file paths in the CSS?).
Also, seeming as the main content of the site will be held in the 'Content' areas of the tabbed panel, I'm wondering what the best approach is for building this site, with regards to NAV and ARTICLE etc, so that is semantically correct?
Perhaps I am going about this the wrong way?
I'm not familiar with SPRY, but you are probably correct in that you will need to edit the CSS if you wish to have more semantic markup.
Assuming each "tab" is it's own article, here is how I would mark this up:
<div id="TabbedPanels1" class="TabbedPanels">
<nav>
<ul class="TabbedPanelsTabGroup">
<li class="TabbedPanelsTab" tabindex="0">Home</li>
<li class="TabbedPanelsTab" tabindex="0">Profile/li>
<li class="TabbedPanelsTab" tabindex="0">Contact</li>
</ul>
</nav>
<div class="TabbedPanelsContentGroup">
<article class="TabbedPanelsContent">Content 1</article>
<article class="TabbedPanelsContent">Content 2</article>
<article class="TabbedPanelsContent">Content 3</article>
</div>
</div>
It isn't a big change, but it adds at least some better semantics to the markup while still leaving the majority of the structure intact so that there don't need to be MASIVE changes to the SPRY framework code.
Related
I am currently working on a website, where the site will have a hero slider at the top of the page, under the navigation. Currently, I have written the code like this:
<header>
<h1 class="site-title">Site Title</h1>
<nav id="primary">
<ul class="top-level">
<li class="link">Link</li>
<li class="link">Link</li>
<li class="link">Link</li>
<li class="link">Link</li>
<li class="link">Link</li>
</ul>
</nav>
</header>
<section id="hero-banner">
<!-- Banner Content -->
</section>
But I am wondering if it would be appropriate to also include the hero slider inside of the <header> tag? In that case, the code would turn into this:
<header>
<h1 class="site-title">Site Title</h1>
<nav id="primary">
<ul class="top-level">
<li class="link">Link</li>
<li class="link">Link</li>
<li class="link">Link</li>
<li class="link">Link</li>
<li class="link">Link</li>
</ul>
</nav>
<section id="hero-banner">
<!-- Banner Content -->
</section>
</header>
Visually, I would consider the hero banner to be grouped with the rest of the <header>, but I'm not sure if reflecting this in the code would be considered semantically correct.
From w3schools:
The element represents a container for introductory content or a set of navigational links.
A element typically contains:
one or more heading elements (<h1> - <h6>)
logo or icon
authorship information
In the end, it's entirely up to you, it's not "bad practice" or "good practice" one way or the other.
It is better to put it outside the <header> tag. As it is not considered as an element of the menu nor the navigation bar. So you are good to go with the first code.
What is a structure for HTML building while you're creating a index file or skeleton of the website? For instance: 1st is a Header, then Navbar etc. And why we nest the divs? isn't it better to put divs separately?
Instead of this:
<div id="header">
<div id="menubar_container">
<div id="menubar">
<div id="welcome">
<h1>Industrial Grey</h1>
</div><!--close welcome-->
<div id="menu_items">
<ul id="menu">
<li class="current">Home</li>
<li>Our Work</li>
<li>Testimonials</li>
<li>Projects</li>
<li>Contact Us</li>
</ul>
</div><!--close menu-->
</div><!--close menubar-->
</div><!--close menubar_container-->
</div><!--close header-->
Just to put all divs separately:
<div id="header">
</div> <!--closing the header div -->
</div id="menubar">enter code here
</div> <!-- closing the menubar div -->
Truth be told I watched hundreds of tutorials, read hundreds of materials, but still don't get the point of nesting the tens of divs ..
Nesting DIVs can make styling the website easier.
Let's say that you want to add a margin to a specific part of your site (like in an article with multiple sections, but not the header or footer). By putting your article's main content in nested DIVs, the margin will be applied to the whole section easily.
(You won't need multiple pieces of CSS to achieve the effect.)
Also, nest DIVs helps you organise the DOM. This may make it easier for you to find a specific part of your code in the Developer tools. Your website will also be more accessible.
TLDR: Nesting DIVs are best practice.
I have an HTML Structure which really has 2 headers: At the tippity top of the page it has some navigation items and buttons, below that is another section which holds the logo and what I would call the main navigation.
Both are sectioned off in wrappers because of full width CSS3 gradients so my structure looks something like this:
<div id="topWrap">
<div id="topNavWrap">
<nav id="utilityLinks">
<ul>
<li>Home</li>
<li>Page</li>
<li>Page</li>
<li>Page</li>
<li>Page</li>
</ul>
</nav>
<div id="quickLinks">
<ul>
<li>Login</li>
<li>Contact</li>
</ul>
</div>
</div>
</div>
<div id="headerWrap">
<div id="header">
<div id="logo"><img src="logo.png" /></div>
<nav id="mainNav">
<ul>
<li>Main Service Page</li>
<li>Main Service Page</li>
<li>Main Service Page</li>
<li>Main Service Page</li>
<li>Main Service Page</li>
</ul>
</nav>
</div>
</div>
My question is:
In this situation is it acceptable to wrap both of these nav elements in a header element, do I just wrap my main nav and logo in a header element, or do I wrap both in one big header element?
When using Aria, should I use role="main" on my main navigation or my main header element?
Yes, it makes sense to use header for both of these.
As header has no influence on the document outline, it’s up to you use one or several header elements; it doesn’t affect the meaning. If there is no reason not to use one element (i.e., there is no content inbetween that should not be part of header), go with one element.
The ARIA role main is for the main content of a page. Navigation is typically not the main content, unless it’s the only content and purpose of a page. However, in that case you wouldn’t use the header element, as its job is to "exclude" content that is not considered to be part of the main content.
If they are using nav elements you shouldn't simply wrap them in headers. Although you can use multiple header elements in a page, they should represent the top of a 'section', a content area.
A more suitable HTML setup would be:
<header id="topWrap" role="banner">
<div id="topNavWrap">
<nav id="utilityLinks" role="navigation" aria-describedby="utilityLinksH2">
<h2 class="at" id="utilityLinksH2">Site menu</h2>
<ul>
<li>Home</li>
...
</ul>
</nav>
<div id="quickLinks">
<ul>
<li>Login</li>
...
</ul>
</div>
</div>
<div id="headerWrap">
<div id="header">
<div id="logo"><img src="logo.png" /></div>
<nav id="mainNav" aria-describedby="mainNavH2">
<h2 class="at" id="mainNavH2">Service menu</h2>
<ul>
<li>Main Service Page</li>
...
</ul>
</nav>
</div>
</div>
</header>
Notable points are:
wrapping the whole lot in a header, with a role of banner. which should only be used once on a page to denote site furniture at the top of the page. (When used from the body the header applies to the, see the last example in the HTML5 spec.)
Labelling each nav with a hidden sub-heading (use .at to move it offscreen), with aria-describedby.
Main should wrap the main content of the page (that is unique to the page), generally starting just above a H1. There should be only one.
I have a problem with Foundation 4 rendering on a small screen.
When on a local server i have the following html code, my custom css is turned of and so is my cutom js. All the needed libraries are loaded correctly as is the foundation library:
Why isnt my topbar showing in a very small browser window?
Below is a html snippet:
<div class="row show-for-touch show-for-portrait show-for-small">
<nav class="top-bar">
<ul class="title-area">
<li class="name">
<h1>title</h1>
</li>
<li class="toggle-topbar menu-icon"><span>Menu</span></li>
</ul>
<section class="top-bar-section">
<ul class="right">
<li><h4>Dungeon</h4></li>
<li><h4>Pricing information</h4></li>
<li><h4>Contact</h4></li>
</ul>
</section>
</nav>
</div>
You won't be able to see your bar in a small browser if you add this visibility class: show-for-touch, which displays only on a real mobile environment.
If you like to see on a small browser, simply remove this class:
<div class="row show-for-portrait show-for-small">
It works on this plunk.
I am a bit stuck on how to section up a mega menu to use the HTML 5 outlining model.
I have created a jsfiddle to show the barebones markup (please ignore the css, it is just a brain dump for the purposes of this question) and will paste this html below as well.
My confusion hinges around the logical association of list items as compared to <section /> tags. In the html provided you will see I have only used <div />s and <ul />s for structuring the markup. If I run this through a outlining tool I get a mess of content, no clear structure. In the actual menu there are about 20 headings or so in the content areas. I have no real control over what these headings are (ie whether they are <h2 />s or <h3 />s etc).
Can anyone please give me some guidance on where to go from here. I have tried wrapping all anchors that have content within their dropdowns in <h2 /> tags, then wrapping these plus the drop content in <section/> tags. This makes the outline look correct but I am not sure if it is, in fact, correct.
I had thought I might be able to use some ARIA roles but, again, I'm confused about how this works with <section />s and headings and list items!
Any advice will be much appreciated!
Thanks
Basic html outline showing the different possible contents of the mega-menu
<nav>
<h2>Main menu</h2>
<ul>
<li class="has-mega">
Level 1 - Mix of varying content and children
<div class="mega">
<ul>
<li class="has-mega">
Level 2
<div class="mega">
<ul>
<li class="has-mega">
Level 3
<div class="mega">
<h2>Heading</h2>
<p>Any content can go here</p>
</div>
</li>
</ul>
</div>
</li>
<li class="has-mega">
Level 2
<div class="mega">
<h2>Heading</h2>
<p>Any content can go here</p>
</div>
</li>
<li>
Level 2
</li>
</ul>
</div>
</li>
<li class="has-mega">
Level 1 - Mix of children
<div class="mega">
<ul>
<li class="has-mega">
Level 2
<div class="mega">
<ul>
<li>
Level 3
</li>
<li>
Level 3
</li>
<li>
Level 3
</li>
</ul>
</div>
</li>
<li>
Level 2
</li>
</ul>
</div>
</li>
<li>
Level 1 - No drop content at all
</li>
</ul>
</nav>