Is this html5 structure correct? [closed] - css

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I've been using an html5 doctype for a while now but haven't really been using many more tags than header, nav and footer. I would like to understand when to implement the article and aside tags and if in my example I am implementing them correctly.
The entire reason that I ask this question is because there seems to be a lot of controversy on how exactly they should be used and whether certain tags like the aside tag can be nested within the article tag. I'm just looking for clarity here.
Here is my example. I have 2 questions:
Is there anything about this layout that is incorrect?
Can I style aside these new tags or do I have to apply styles to the elements within the new html5 tags?
<header>
</header>
<main>
<article id="article">
<div id="full">
<aside id="page-left">
<div>
<h1>title</h1>
<p>content</p>
</div>
</aside>
<aside id="page-right">
<div>
<h2>title</h2>
<p>content</p>
</div>
</aside>
</div>
</article>
</main>
<footer>
</footer>
EDIT:
What I am after is simply a wrapper div that was changed to an article tag that will contain 2 inline elements. The left element will contain the actual article and the right side will contain testimonials.
What would the correct tags be in this case?

From W3C:
--
The article element represents a complete, or self-contained, composition in a document, page, application, or site and that is, in principle, independently distributable or reusable, e.g. in syndication. This could be a forum post, a magazine or newspaper article, a blog entry, a user-submitted comment, an interactive widget or gadget, or any other independent item of content. Each article should be identified, typically by including a heading (h1-h6 element) as a child of the article element.
A general rule is that the article element is appropriate only if the element's contents would be listed explicitly in the document's outline.
--
The aside element represents a section of a page that consists of content that is tangentially related to the content around the aside element, and which could be considered separate from that content. Such sections are often represented as sidebars in printed typography.
The element can be used for typographical effects like pull quotes or sidebars, for advertising, for groups of nav elements, and for other content that is considered separate from the main content of the page.
--
So I would not put the article content inside an aside tag.
more here

One would normally put ads and other stuff that has nothing - or less - to do with the article, in aside tags. I can't tell you if you're using them properly since only you can decide whats necessary and what's not. But I guess you're using them fine. just make sure you don't put important stuff in them because google and other search engines won't show anything in aside tags in your websites description
EDIT: this is how - I think - your example should look:
</header>
<main>
<div id="full">
<article id="page-left">
<div>
<h1>title</h1>
<p>content</p>
</div>
</article>
<aside id="page-right">
<div>
<h2>title</h2>
<p>content</p>
</div>
</aside>
</div>
</main>
<footer>
</footer>

Related

<main> tag as a column wrapper

Let's say that I have a website with a header, two columns under it (one as a wrapper for articles and the other as a sidebar). Now, can I use main as a wrapper for those articles:
<main>
(articles here)
</main>
<aside class="sidebar">
(sidebar here)
</aside>
Or should I wrap this <main> with <div>?
<div id="left-column">
<main>
(articles here)
</main>
</div>
<aside class="sidebar">
(sidebar here)
</aside>
In general: can we use semantic tags also for styling/display purposes with CSS (which is normally the domain of div elements)?
You should not add those semantic elements just because you need CSS hooks, but if your use of the elements is appropriate, it is perfectly fine, and a good practice, to use them also as hooks for CSS.
If you need more than your existing elements for styling reasons, add span/div elements (as they are the only "non-semantic"/meaningless elements).
Adding span/div around every semantic element you want to style would bloat your markup, and make it harder to understand/maintain. There can be one reason for doing it for the elements introduced with HTML5 (like main), though: If you need to achieve a certain styling in old browsers which don’t support these new elements.
"New" HTML5 elements are elements like any other (OK not input[type="hidden"] or head ^^ but div or span or p or h6). They bring semantics but when it comes to styling, in browsers supporting them which is IE9+ (except maybe for main), you can display: flex them or float or position: relative or even display: inline.
IE8 needed a polyfill named htmlshiv but that's oooold. Don't support IE8 (because MS doesn't even support the OS where it could run!)
I'd include aside as an aside to main and preceding sibling could be an article or section.
<main role="main">
<article><!-- or section? -->
(articles here)
</article>
<aside class="sidebar">
(sidebar here)
</aside>
</main>

HTML5 article tag: pre article content?

My question is probably based on a bad design. However, I can't change that and need to work with it. This is the visual draft I'm talking about, it's just a part of a full website:
As you can see there's a title of an article with a background image, then a breadcrumb toolbar and finally, the articles content. Now, usually, if there wouldn't be the breadcrumb toolbar you could simply wrap it into an <article>. But the breadcrumb divides the article in a "pre" article and a main article part. The only "clean" HTML5 way would be to wrap the article including the header with background image into an <article> and position the breadcrumb into the target visual position. However, I'm classifying this as "hack" and I'm searching a better way.
What would be the preferred markup for this scenario?
There won't be any perfect the solution for the current requirement.
As pointed out by comments to the previous answer, the nav is not related to the article.
Also, WCAG instructs that :
1.3.2 Meaningful Sequence: When the sequence in which content is presented affects its meaning, a correct reading sequence can be programmatically determined. (Level A)
EDIT : If changing the order of the element can preserve a meaningful sequence (G57), when the elements does not match visually the DOM order (see C27) the visual focus indicator of the screen reader will not match the standard reading order which will result in bad UX for people with low vision using a screenreader.
So it's impossible to try a CSS visual hack to invert the order between the elements visually without breaking another rule.
You may think of a third technique :
set aria-hidden on the visible title,
use aria-labelledby on the article tag to point to the h1 outside the article element :
For instance:
<header>
<h1 aria-hidden="true" id="title">Your title</h1>
<nav><!-- nav here --></nav>
</header>
<article aria-labelledby="title">
// article here
</article>
Another way to do is to duplicate the title element, one visible, one for assistive technology
<header>
<div aria-hidden="true">Your title</div>
<nav><!-- nav here --></nav>
</header>
<article>
<h1 class="sr-only">Your title</h1>
// article here
</article>
It could be something like this -
<article>
<header>
//APPLY BACKGROUND IMAGE
<h1>YOUR TITLE</h1>
</header>
<nav>
//USE BREADCRUMBS HERE
</nav>
<section>
//USE THIS FOR CONTENT
</section>
</article>

Best practices for HTML and divs [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I would like to know the best way of using HTML5 and div tags together. I have posted my html below.
I am using the article tag then I have sections which I am sure are correct, but I am using grids as well, so where should I put the grid div?
Is my method the best way of doing it?
<article>
<div class="grid-wrapper">
<section>
<div class="grid-4-col">
<h1>Welcome Back</h1>
<p>It has been a while. What have you been up to lately?</p>
</div>
</section>
<section>
<div class="grid-4-col">
<h1>Welcome Back</h1>
<p>It has been a while. What have you been up to lately?</p>
</div>
</section>
<section>
<div class="grid-4-col">
<h1>Welcome Back</h1>
<p>It has been a while. What have you been up to lately?</p>
</div>
</section>
<section>
<div class="grid-4-col grid-last">
<h3>Chicago</h3>
<h5 hidden>City in Illinois</h5>
<img src="chicago.jpg" alt="Chicago, the third most populous city in the United States">
<ul>
<li>234 square miles</li>
<li>2.715 million residents</li>
</ul>
</div>
</section>
</div>
</article>
According to HTML5Doctor, the way you've gone about it is fine. You're effectively using the divs as wrappers and that's permitted.
Source: http://html5doctor.com/you-can-still-use-div/
Since you are using a grid system, and a section element sections off content, you want the section to be inside the grid, which is defined by the div. So put the section element inside the div. Otherwise, your grid is relative to the section and not the whole page and grid system.

Correct use of article, aside, and header tags

I have a simple page template that has a sidebar on the left and main content area on the right. Is this the correct use of the article, aside, and header tags? Also, are you suppose to attach classes/ids to html5 elements (ie. article class="example" ) or is that specifically for divs only?
Thanks
<article class="page">
<div class="container">
<div class="row">
<aside>
<div class="col-md-3">
<div class="sidebar">
<h3>Sidebar Widget</h3>
<ul>
<li>Related Content</li>
<li>Related Content</li>
<li>Related Content</li>
</ul>
</div> <!-- /.sidebar-->
</div> <!-- /.col-med-3 -->
<aside>
<div class="col-md-9">
<header>
<h1 class="page-title">Page Title</h1>
</header>
<p>Some Content</p>
</div> <!-- /.col-med-9 -->
</div><!-- /.row -->
</div><!-- /.container-->
</article><!-- /.page -->
You can certainly apply a class and/or an id to HTML5 tags. Think of each tag like a <div>. In fact, in your CSS you should have this block, so that all HTML5 tags will behave like a <div>. This will help in non-HTML5 compliant browsers:
header, section, footer, aside, nav, article, figure {
display: block;
}
I can't really comment on if you are using all of the HTML5 tags in the "correct" way since I don't know the larger scope of your project. However, it looks like you are using the <aside> correctly. I would use <section> instead of <article> where you used it. Here are some explanations in plain English to help you:
<article> - Independent, self-contained content. It should be able to stand on it's own and make sense if separated from the rest of the HTML document. The most notable potential uses are for forum/blog posts, user comments, etc.
<aside> - Supporting information about the larger picture of your HTML. These are mostly used in sidebars, to the left or right of the main content as part of the "supporting cast".
<header> - As the name suggests, this is where your heading information should go. Multiple <header> tags can be used throughout your HTML page (i.e. for blog post headings), but they cannot be added in <footer>, <address> or another <header> tag.
<section> - More of a "general purpose" tag, but it's used for containing large blocks of grouped content. Multiple HTML5 tags can reside inside of a <section> tag.
It is totally normal to put ids and classes on any/all html elements.
Your usage of <article> and '' are probably too widely scoped.
The <article> element represents a component of a page that consists of a self-contained composition in a document, page, application, or site and that is intended to be independently distributable or reusable, e.g. in syndication. Source
The <aside> element represents a section of a page that consists of content that is tangentially related to the content around the aside element, and which could be considered separate from that content. Source

Semantically marking up a page to fit visual design [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Am trying to decide the best way to markup this design I'm working on. The quick outline of it is here:
It's a news article.. so I'd like to use the article tag and then some aside information. My issue is the design layout of it.. the h1 of the article spans over the 2 columns.. I want to use article tag for the h1, publish information and main body.. but in order to do that and fit the design I'd have to include the rightcolumn inside the article which is not great semantically. The information in the right column is common to lots of pages so shouldn't be part of an aside.
So at the moment I'm thinking along the lines of
<h1>News article title</h1>
<div class="leftcol">
<article>
<p>publish information</p>
<p>Main body in general markup</p>
</article>
<aside>
Related content here
</aside>
</div> <!-- end left col -->
<div class="rightcolumn">
Contact form code, followed by customer quote stuff
</div> <!-- end right column -->
I'm concerned about leaving the H1 outside the article tag - Seems like it kind of defeats the purpose, but I'm not sure what other way would work. Possible repeat of the h1 tag inside the article as well but that's definitely not ideal..
What is the most semantically correct way of marking this design up?
*ED
Can't do opinion based questions.. but in case anyone else is considering the same thing (and not allowed to ask it) I went with the following:
<div class="page-heading">News article title</div>
<div class="leftcol">
<article>
<h1>News article title</h1>
<p>publish information</p>
<p>Main body in general markup</p>
</article>
<aside>
Related content here
</aside>
</div> <!-- end left col -->
<div class="rightcolumn">
Contact form code, followed by customer quote stuff
</div> <!-- end right column -->
Decided to keep the h1 within the article (and hide it with css) and then just use a div outside the columns with the same content to hold true to the design.

Resources