{"id":248,"date":"2021-06-07T13:43:32","date_gmt":"2021-06-07T12:43:32","guid":{"rendered":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/?page_id=248"},"modified":"2021-06-07T21:58:39","modified_gmt":"2021-06-07T20:58:39","slug":"horizontal-navigation-bars","status":"publish","type":"page","link":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/html\/horizontal-navigation-bars\/","title":{"rendered":"Horizontal Navigation Bars"},"content":{"rendered":"<h1><img loading=\"lazy\" decoding=\"async\" class=\"alignright wp-image-197\" style=\"margin-top: 0.857143rem;margin-bottom: 0.857143rem;margin-left: 1.71429rem\" src=\"https:\/\/glow-prod-sh.s3.eu-west-1.amazonaws.com\/sh\/public\/ahscomputinghtml\/uploads\/sites\/3275\/2021\/06\/05211153\/sqa-h-150x150.png?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&#038;X-Amz-Security-Token=IQoJb3JpZ2luX2VjEMT%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCWV1LXdlc3QtMSJGMEQCIGugESV4wLRedzh9FQKCWjMO6n2NOhM5q6UyVt4d9i2GAiAjwoZXcjf%2BtU5KD15qnWf8mOZGcSkcD9YUtL4xhk6CKCrCBQiN%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F8BEAUaDDI3MzU3MDE5NTQzMyIMkVYMvNfs9GfecU80KpYF9V9sibbzrJL%2BKJieMEfCXz3cmP9Ge54Ul4rBu%2BgOvBqAv1hSXN9sHlKjGxclpD0HHxsMHmUrrh3j0UQSor2WwCQrz7%2FUlLXoBY0gWVkWs8PtZS%2BdMaY9hTaBrkdQIqE363LgEDJhKV1W5yMAlxe5E0L9byDAskoRvxHSqfQLuIZn16D68fxL35PyHLkM4HIO1yufHLvIDwIK6Ju79fcfCg6nSyPXUuFdk9bvcQRtLcOB1iuvvBmNxjQ5X2g9FBokoaX5mDjWjnHY9wL7knMBMRyhrI0JgKZ4l%2F3MdyyRaceTjZOEEap08B%2Fsyu6twOUAzTxbxBMdQRtEwP0XBcTJblCtl2FTfY6iu3%2FckIoCpJAoQ7ntN45j7b%2FphyJKjAiUPyZu5FNeF0RvF6hEWlFFUlLsAYVxLrguQN8vNc5Yv7Td2wR7NPvyGPJtQpwYX4hiGjjSYQKOxT8YRpQc92yzeb7KkQXwuz2BQ7Mw%2B%2F%2BpgsCQpKWPy31%2Fc4SGKXSoTJ7xKNgdnTfOGkmI4pbhcKhxfFNOmQVXnAdOL5XV5aXZSga7OG3vBzaXGDFMRxarxh2NaXwVeoSU4kudvYKwc4Wklydexs2GdpqQ%2FbxiAE9QkF2TfESsOi4ysnO5JTQ4gCqb3XmPspv%2FP1UzRVim1nFDoI4NV8jQf2f50JkXUs%2FW0Jo%2BdmV7h1cERyWYkSV6stYcJz7RMCHCbxlZKokJ5JptlBejGtyo3WcppkDGrakpFbkUf542K4Jj23tk90Y6EV2yPYp7KfCn5l29LhOC8F%2B%2BxzS3bzfptYeEnb8ZXDt5e9yE0QOSTxndgDEs9MbdbaAA6rLk%2BMspCNj5W%2BwGS0YyEQM8KWvBGS%2B9k0QMyfjc2vh8h%2F5xhXIwsrGh0AY6sgGC40YFyCu3Nzm3BxIyEYLc5nwgUZ6%2Flas1CObgEVW3l2IqPv8Kk%2FzLrpgU5WIr98bMv2JVJwTTBgUrJ3kc8ZzriByNRkdwIahA1cLkjUPlfe5bOJK7Cuh%2FnAECAw8uu3yAfGEwOK7f1Cg0mHn2kxm3SsY7%2FA8TFtkurn8NLKYsM0jRRZ2CAta%2BS9aH%2B1FVREtW%2BKvypDJ9Ni6DKuofSeiE2plkVj6u%2BUevQyJ9xODuy4zi&#038;X-Amz-Algorithm=AWS4-HMAC-SHA256&#038;X-Amz-Credential=ASIAT7MQN47UVLUTULUV%2F20260516%2Feu-west-1%2Fs3%2Faws4_request&#038;X-Amz-Date=20260516T121546Z&#038;X-Amz-SignedHeaders=host&#038;X-Amz-Expires=900&#038;X-Amz-Signature=ac0f94b9863f6db29337b040103f3991d5e190d1ca26023339820c34d6b832c7\" alt=\"\" width=\"100\" height=\"97\" \/>List of Links<\/h1>\n<p>The HTML 5 &lt;nav&gt; element is used to contain website navigation links, usually as a navigation bar.<\/p>\n<p>The navigation bar is declared as an unordered list of hyperlinks:<\/p>\n<pre class=\"brush: xml; title: HTML; notranslate\" title=\"HTML\">\r\n&lt;nav&gt;\r\n    &lt;ul&gt;\r\n        &lt;li&gt;&lt;a href=&quot;home.html&quot;&gt;Home&lt;\/a&gt;&lt;\/li&gt;\r\n        &lt;li&gt;&lt;a href=&quot;sport.html&quot;&gt;Sport&lt;\/a&gt;&lt;\/li&gt;\r\n        &lt;li&gt;&lt;a href=&quot;music.html&quot;&gt;Music&lt;\/a&gt;&lt;\/li&gt;\r\n        &lt;li&gt;&lt;a href=&quot;study.html&quot;&gt;Study&lt;\/a&gt;&lt;\/li&gt;\r\n        &lt;li&gt;&lt;a href=&quot;drama.html&quot;&gt;Drama&lt;\/a&gt;&lt;\/li&gt;\r\n    &lt;\/ul&gt;\r\n&lt;\/nav&gt;\r\n<\/pre>\n<h1>CSS Formatting<\/h1>\n<p>Note: This topic uses CSS <a href=\"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/css\/selectors-classes-and-ids\/\">Descendant Selectors<\/a>.<\/p>\n<h2>Remove the bullet points from the &lt;li&gt; elements<\/h2>\n<pre class=\"brush: css; title: CSS; notranslate\" title=\"CSS\">\r\nnav ul {\r\n    list-style-type:none;\r\n}\r\n<\/pre>\n<h2>Position list items horizontally, evenly spaced out<\/h2>\n<p>Each list item is centred in an 80px wide box, and floated so they are displayed alongside each other<\/p>\n<pre class=\"brush: css; title: CSS; notranslate\" title=\"CSS\">\r\nnav ul li {\r\n    float:left;\r\n    width:80px;\r\n    text-align:center;\r\n}\r\n<\/pre>\n<h2>Creating clickable boxes<\/h2>\n<p>In most navigation bars, clicking the area around the hyperlink also selects the link. A clickable box area around the link text is achieved by displaying the &lt;a&gt; element as a block. This is made visible by giving each link a border and a background colour.<\/p>\n<p>Padding is used to add some (vertical) space around the text for the link.<\/p>\n<p>The underlining can also be removed from the hyperlinks at in the same block.<\/p>\n<pre class=\"brush: css; title: CSS; notranslate\" title=\"CSS\">\r\nnav ul li a {\r\n    display:block;\r\n    padding:8px;\r\n    background-color:wheat;\r\n    border: 1px solid black;\r\n    text-decoration:none; \r\n}\r\n<\/pre>\n<h2>Adding interactive colours<\/h2>\n<p>The state of the &lt;a&gt; element can be styled to change the background colour and text colour of each link when the mouse hovers over an &lt;a&gt; element:<\/p>\n<pre class=\"brush: css; title: CSS; notranslate\" title=\"CSS\">\r\nnav ul li a:hover {\r\n    background-color:#000;\r\n    color:white;\r\n}<\/pre>\n<h2>Complete HTML and CSS<\/h2>\n<pre class=\"brush: xml; title: HTML; notranslate\" title=\"HTML\">\r\n&lt;nav&gt;\r\n    &lt;ul&gt;\r\n        &lt;li&gt;&lt;a href=&quot;home.html&quot;&gt;Home&lt;\/a&gt;&lt;\/li&gt;\r\n        &lt;li&gt;&lt;a href=&quot;sport.html&quot;&gt;Sport&lt;\/a&gt;&lt;\/li&gt;\r\n        &lt;li&gt;&lt;a href=&quot;music.html&quot;&gt;Music&lt;\/a&gt;&lt;\/li&gt;\r\n        &lt;li&gt;&lt;a href=&quot;study.html&quot;&gt;Study&lt;\/a&gt;&lt;\/li&gt;\r\n        &lt;li&gt;&lt;a href=&quot;drama.html&quot;&gt;Drama&lt;\/a&gt;&lt;\/li&gt;\r\n    &lt;\/ul&gt;\r\n&lt;\/nav&gt;\r\n<\/pre>\n<pre class=\"brush: css; title: CSS; notranslate\" title=\"CSS\">\r\nnav ul {\r\n        list-style-type:none;\r\n}\r\n\r\nnav ul li {\r\n        float:left;\r\n\t\twidth:80px;\r\n\t\ttext-align:center;\r\n}\r\n\r\n\r\nnav ul li a {\r\n    display:block;\r\n\tpadding:8px;\r\n    background-color:wheat;\r\n\tborder: 1px solid black;\r\n\ttext-decoration:none; \r\n}\r\n\r\nnav ul li a:hover {\r\n    background-color:#000;\r\n\tcolor:white;\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>List of Links The HTML 5 &lt;nav&gt; element is used to contain website navigation links, usually as a navigation bar. The navigation bar is declared as an unordered list of hyperlinks: &lt;nav&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;home.html&quot;&gt;Home&lt;\/a&gt;&lt;\/li&gt; &lt;li&gt;&lt;a href=&quot;sport.html&quot;&gt;Sport&lt;\/a&gt;&lt;\/li&gt; &lt;li&gt;&lt;a href=&quot;music.html&quot;&gt;Music&lt;\/a&gt;&lt;\/li&gt; &lt;li&gt;&lt;a href=&quot;study.html&quot;&gt;Study&lt;\/a&gt;&lt;\/li&gt; &lt;li&gt;&lt;a href=&quot;drama.html&quot;&gt;Drama&lt;\/a&gt;&lt;\/li&gt; &lt;\/ul&gt; &lt;\/nav&gt; CSS Formatting Note: This topic uses CSS Descendant Selectors. Remove the bullet points from the &lt;li&gt; elements nav ul { list-style-type:none; } Position list items<\/p>\n<p><a class=\"more-link\" href=\"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/html\/horizontal-navigation-bars\/\">Read More<\/a><\/p>\n","protected":false},"author":7,"featured_media":0,"parent":16,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-248","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/wp-json\/wp\/v2\/pages\/248","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/wp-json\/wp\/v2\/comments?post=248"}],"version-history":[{"count":8,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/wp-json\/wp\/v2\/pages\/248\/revisions"}],"predecessor-version":[{"id":290,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/wp-json\/wp\/v2\/pages\/248\/revisions\/290"}],"up":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/wp-json\/wp\/v2\/pages\/16"}],"wp:attachment":[{"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputinghtml\/wp-json\/wp\/v2\/media?parent=248"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}