Jump to content

Use of 'main' tag in HTML5


shaijuelayidath
 Share

Recommended Posts

Hello Friends,

 

Recently i have read about 'main' tag is introduced in HTML5, but i could'nt found anywhere explained about the proper use of this tag. Means, everywhere explaining it is for main content of the website, but I would like to know that can we put 'section' and 'aside' tag within the 'main' tag. This is only i want to know.

 

Thanks in advance!

Link to comment
Share on other sites

Hello Tezzo,

 

Actually can I put 'section' and 'aside' tag inside of a 'main' tag. Because some are says 'main' tag is only for main content of the webpage and 'aside' tag is for secondary contents. So, 'main' and 'aside' tags are separate blocks which comes in a section or div. The links you have send is good but did you listen, there is no clearly says what elements can be contain by the 'main' tag. I searched few but nowhere is discussing about this term.

 

Thanks!

Link to comment
Share on other sites

Note: There must not be more than one <main> element in a document. The <main> element must NOT be a descendant of an <article>, <aside>, <footer>, <header>, or <nav> element.

 

Copied from w3schools link

Link to comment
Share on other sites

even i have had this discussion with my mates......and i have put the same point.... aside which is considered as a holding content to your main flow...why do you want to rate it<main>.......and if you think it is main you should include it in our main flow....

Link to comment
Share on other sites

The <main> tag is for content that is unique to the page. Headers, navigation and footers go outside the <main> tag, everything else goes inside it.

 

Here's a basic HTML 5 document structure:

<header><h1>Site name</h1></header><nav>    <ul>        <li><a href="#">Nav link</a></li>        <li><a href="#">Nav link</a></li>        <li><a href="#">Nav link</a></li>    </ul></nav><main>   <h2>Page title</h2>    <section>        <h3>Section 1</h3>        <p>Content of section 1</p>    </section>    <section>        <h3>Section 2</h3>        <p>Content of section 2</p>    </section></main><footer>    <nav><!-- Perhaps a few footer navigation links --></nav>    <p>Some more footer content</p></footer>

Navigation tags can go inside or outside the <header> and <footer> elements, it doesn't matter.

Link to comment
Share on other sites

Hello Ingolme, Tezzo, musakilimanjaro,

 

Basically I need a two column layout for content section.

Please take a look at my following 2 HTML codes. Let me know No.1 or No.2 is right ?

----------------------------------------------------------------------------------------------------

No.1

----------------------------------------------------------------------------------------------------

<main>

<section> <-- main content goes here -->
<aside> <--- subcontent goes here -->
</main>

----------------------------------------------------------------------------------------------------

No.2

----------------------------------------------------------------------------------------------------

<section>
<main> <--- main content goes here -->
<aside> <--- subcontent goes hee -->
</section>

----------------------------------------------------------------------------------------------------

let me know which one can be use. Because nowhere is discussed about <aside> tag can be put inside of <main> tag.
Thanks!
Link to comment
Share on other sites

If the <aside> element has content that's unique to the page (in every page on your site something different is there) then you should put it inside the <main> tag. The <main> element should encompass everything that is unique to the page.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...