I simply want to navigate from one page to a specific point on another.
I have a home page with four sections:
<section>
<a name="section1"></a>
</section>
<section id="section2">
</section>
<section>
<a name="section3"></a>
</section>
<section id="section4">
</section>
Section 2 and 4 feature on every page, so my nav looks like:
<nav>
<ul>
<li>ABOUT</li>
<li>APARTMENTS</li>
<li>LANDLORDS</li>
<li>CONTACT</li>
</ul>
</nav>
The links aren't navigating to the index page or the desired section of the index page.
Now I have:
<section>
<a name="section1"></a>
</section>
<section id="section2">
</section>
<section>
<a name="section3"></a>
</section>
<section id="section4">
</section>
And my navigation:
<nav>
<ul>
<li>ABOUT</li>
<li>APARTMENTS</li>
<li>LANDLORDS</li>
<li>CONTACT</li>
</ul>
</nav>
It is still not working.
Are you sure that you have placed the files in the same directory? I've tested the code that you have provided and it's working. However, you could try this out (a different way of giving sections an id):
<section>
<a id="section1">
CONTENT
</a>
</section>
If you have done this, just use the same way of linking:
Section One
Check your JavaScript code for the line that says "event.preventDefault();".
I found this in a W3Schools Bootstrap template that included this command as part of a <nav> block that makes a nice scroll to the hashtag. Once I commented it out, the links worked fine.
I think you are facing this issue with a legacy browser (Internet Explorer 8 and below). Because I have tested it in Firefox, Chrome, and Internet Explorer 9. It's working fine. But it failed in legacy browsers.
For that, you have to use the anchor tag (a) instead of div id.
Example:
<a name="section1"></a>
<section>section content goes here </section>
<a name="section2"></a>
<section>section content goes here </section>
<a name="section3"></a>
<section>section content goes here </section>
<a name="section4"></a>
<section>section content goes here </section>
Now you can use any class name you want for your section elements...
You need an a-name tag, please see
http://www.w3schools.com/tags/att_a_name.asp
Related
<header>
<div class="menu-toggler">
<div class="bar half start"></div>
<div class="bar half"></div>
<div class="bar half end"></div>
</div>
<nav class="top-nav" role='navigation'>
<ul class="nav-list">
<li>
Home
</li>
<li>
About
</li>
<li>
Services
</li>
<li>
Portfolio
</li>
<li>
Experience
</li>
<li>
Contact
</li>
</ul>
</nav>
<div class="landing-text">
<h1>Ali Temel</h1>
<h6>Junior Front-End Developer</h6>
</div>
</header>
Dear Stackoverflow users,
This my very first question. I am an intended web developer. I really tried to link my sections but i cannot jump into section when i click Experience or About section. I appreciate for your help. This is an awesome community. Now i can get a chance to sign up.
https://github.com/alitemel89/personalwebsite-v1
Sincerely,
Ali
In order for anchor links to work the structure needs to be like this:
About
<div id="about">About content</div>
Check this for more fancy stuff related to this.
https://css-tricks.com/hash-tag-links-padding/
I took a look at your code. The problem is that the menu screen doesn't go away.
For example,
When you click on the #about button it goes to the about section but the problem is that your overlay doesn't go away.
-You have to make it, so on click the overlay goes away.
-Your syntax for moving sections is good no need to change that
Im new in coding. I'm making my first website (mobile first). It were all fine, all divs working, responsive, all great! But now I added a new div(nothing special I guess) but when I try to just put a single code (even without media queries) it doesn't work in mobile version. Tablet and desktop are working correctly. I tried to modify other divs and they work fine too.
Here is the code.
HTML
<section class="flvcko-wear">
<ul class="lista-articulos">
<div class="articulo">
<li>
<img src="img/cap.png" alt="">
<p>Flvcko cap</p>
</li>
</div>
</ul>
</section
CSS
.flvcko-wear ul{
list-style-type: none;
}
It doesn't even recognize the 'list-style-type:none;'
It's probably caused by that weird HTML structure – div is not allowed as child of ul (try pasting your code into HTML validator).
This would make more sense:
<section class="flvcko-wear">
<ul class="lista-articulos">
<li>
<div class="articulo">
<img src="…" alt="…">
<p>…</p>
</div>
</li>
</ul>
</section>
Or even omitting the div altogether, since you can style li, too:
<section class="flvcko-wear">
<ul class="lista-articulos">
<li class="articulo">
<img src="…" alt="…">
<p>…</p>
</li>
</ul>
</section>
I agree with the previous answer, try eliminating the div. Try changing your code to the following:
HTML:
<section class="flvcko-wear">
<ul class="lista-articulos">
<li>
<img src="img/cap.png" alt="">
<p>Flvcko cap</p>
</li>
</ul>
</section>
CSS:
ul.lista-articulos {list-style-type: none;}
This is my website code in HTML 5 In this code we make some sections as u see header banner and nav As I dont understand why we write Header Banner And Nav separately while in same Code And whats the main reason behind making these sections? And I dont understand That Banner Code Why we Use Banner Code?
<!-- Header -->
<header id="header">
<div class="logo container">
<div>
<h1>Malik Waqar Azim</h1>
<br><br>
<p>Bachelors in Software Engineering</p>
</div>
</div>
</header>
<!-- Nav -->
<nav id="nav">
<ul>
<li>Home</li>
<li class="current">About Me</li>
<li>Contact Me</li>
</ul>
</nav>
<!-- Banner -->
<div id="banner-wrapper">
<section id="banner">
<h2>About Me</h2>
<p>I am currently pursuing bachelors in software engineering at UET Taxila.</p>
<p>I completed my intermediate and matriculation from Fauji Foundation College Lalazar</p>
</section>
</div>
Different sections in html5 language are like boxes for some content. HTML5 language make structure of document of your webpage. Every web browser has their own standard CSS style. If you didn't link custom style, it use this one to know how to show the html elements.
This banner is div - box in which there are informations about you. In this example you have id of div. The 'id' attribute is neccessery if you want to set some styles for this particular box.
Is the order of the heading, content and footer of a section matter ?
for Example,
is this logical ordering :
<article>
<h1>This is the heading</h1>
<content><p>This is the content ...</p></content>
<footer><p>this is the footer</p></footer>
</article>
same for computers comparing to the next illogical ordering :
<article>
<content><p>This is the content ...</p></content>
<footer><p>this is the footer</p></footer>
<h1>This is the heading</h1>
</article>
Semantic markup and accessibility are both important when writing HTML, you have to keep in mind what makes sense to both machines and end users.
Sure, you "could" put elements in any order and style them so they appear to be in a completely different order, but what happens when someone views your website with a screen reader or something similar.
In addition to this the order of your elements is very important when SEO is concerned, the automated search bots that crawl your website don't care what the page "looks" like and have a very structured way in which they identify key areas such as navigation, main content areas, headings and links.
Positioning isn't black and white either, you could have multiple footer elements on one page which would be perfectly fine as long as you have a way to express which footer related to the parent page which is done using an ARIA role.
<body>
<article>
Something
<footer>Something else</footer>
</article>
<footer role="contentinfo">
</footer>
</body>
This will identify the footer with the role as a "navigational landmark", as footers primarily store navigation.
The same goes for a nav element, you could use it for any type of sub-navigation within your website multiple times in whatever order you'd like in addition to using it for your primary navigation as long as you used role="navigation" on the primary nav.
http://www.w3.org/TR/wai-aria/roles
It's very easy to get carried away with using HTML5 elements but as long as you keep them structured semantically within their parent elements and give machines a way to identify key areas of your markup you will be A-OK.
<body>
<header role="banner">
<nav role="navigation">
<ul>
<li>Home</li>
</ul>
</nav>
</header>
<article role="main">
<header>
<h1>Article Heading</h1>
</header>
<aside>
<nav>
<ul>
<li>Article 1a</li>
<li>Article 1b</li>
<li>Article 1c</li>
</ul>
</nav>
</aside>
<p>Yip, dippidy doo.</p>
<section role="complementary">
<h2>Top Articles</h2>
<nav>
<ul>
<li>Article 2</li>
<li>Article 3</li>
<li>Article 4</li>
</ul>
</nav>
</section>
<footer>
<nav>
<ul>
<li>PrevArticle</li>
<li>Next Article</li>
</ul>
</nav>
</footer>
</article>
<footer role="contentinfo">
Copyright
<nav>
<ul>
<li>Home</li>
</ul>
</nav>
</footer>
</body>
In HTML, yes. Element order is significant. (That is not necessarily the case with other SGML/XML derived markup languages).
This is trivial enough to test by looking at the output in a web browser (the standard tool for presenting HTML to the reader) and noticing that the rendered document doesn't make sense.
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.