The Importance of Proper Navigational CSS

Developer
Size
3,165 Kb
Views
34,408

How do I make an the importance of proper navigational css?

A simple demo to show why not setting display: block; on navigational anchor tags is poor UX.In the first demo, the anchor tag is display: inline-block; and the link is only clickable when the text is hovered.. What is a the importance of proper navigational css? How do you make a the importance of proper navigational css? This script and codes were developed by Chris Burnell on 16 September 2022, Friday.

The Importance of Proper Navigational CSS Previews

The Importance of Proper Navigational CSS - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>The Importance of Proper Navigational CSS</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ body { color: #333; font: 400 13px/1.618 "Helvetica Neue", Arial, serif; padding-bottom: 30px;
}
h1, p, ul, a { text-align: center; margin: 0 auto;
}
h1 { margin: 30px 0 10px; clear: both; font-size: 22px; font-weight: bold;
}
p { width: 620px; text-align: justify; clear: both;
}
ul { width: 620px; height: 30px; margin-bottom: 15px; clear: both;
}
li { background: rgba(0,0,0,.1); width: 200px; float: left;
}
li:not(:last-child) { margin-right: 10px;
}
a { color: #444; font: 700 16px/40px "Helvetica Neue", Arial, serif; text-decoration: none; text-transform: uppercase;
}
a:hover { background: #444; color: #f9f9f9;
}
.second-demo li a { width: 100%; display: block;
}
.third-demo li { width: 170px; padding: 0 15px;
}
.third-demo li a { display: block; width: 100%;
}
.fourth-demo li a { width: auto; padding: 0 15px; display: block;
}
code { font-family: Monaco, 'Courier New', monospace; font-size: .8125em;
}
em { font-style: italic; }
.correct { color: #2ec740; }
.incorrect { color: #bd1717; } </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <h1 class="incorrect">&times; No styling on anchor</h1>
<ul class="first-demo"> <li><a href="#">Item One</a></li> <li><a href="#">Item One</a></li> <li><a href="#">Item One</a></li>
</ul>
<p>Anchor tags have no <code>display</code> declaration here.</p>
<p>Height of the list items is dictated by the line-height of the anchors throughout.</p>
<h1 class="correct">&radic; a { display: block; width: 100%; }</h1>
<ul class="second-demo"> <li><a href="#">Item One</a></li> <li><a href="#">Item One</a></li> <li><a href="#">Item One</a></li>
</ul>
<p>Anchor tags are declared as <code>display: block;</code> <code>width: 100%;</code> here.</p>
<p>The user can now click anywhere within the list item and it will register a click on the anchor as well because each anchor sits on top of/above its parent list item.</p>
<h1 class="incorrect">&times; li { padding: 0 15px; } a { display: block; width: auto; }</h1>
<ul class="third-demo"> <li><a href="#">Item One</a></li> <li><a href="#">Item One</a></li> <li><a href="#">Item One</a></li>
</ul>
<p>List items have <code>padding: 15px;</code> here. Because the anchors are childen of the list items, they can only expand as big as the <code>width</code> constraints of the parent list items&mdash;170px.</p>
<h1 class="correct">&radic; a { padding: 0 15px; display: block; width: auto; }</h1>
<ul class="fourth-demo"> <li><a href="#">Item One</a></li> <li><a href="#">Item One</a></li> <li><a href="#">Item One</a></li>
</ul>
<p>Anchor tags are declared as <code>display: block;</code> &amp; <code>width: auto;</code> and <code>padding: 0 15px;</code> here.</p>
<p>Clicking anywhere within the list item works here as well, as long as things like <code>padding</code> or <code>border</code> are set on the anchor, not the parent list item.</p>
</body>
</html>

The Importance of Proper Navigational CSS - Script Codes CSS Codes

body { color: #333; font: 400 13px/1.618 "Helvetica Neue", Arial, serif; padding-bottom: 30px;
}
h1, p, ul, a { text-align: center; margin: 0 auto;
}
h1 { margin: 30px 0 10px; clear: both; font-size: 22px; font-weight: bold;
}
p { width: 620px; text-align: justify; clear: both;
}
ul { width: 620px; height: 30px; margin-bottom: 15px; clear: both;
}
li { background: rgba(0,0,0,.1); width: 200px; float: left;
}
li:not(:last-child) { margin-right: 10px;
}
a { color: #444; font: 700 16px/40px "Helvetica Neue", Arial, serif; text-decoration: none; text-transform: uppercase;
}
a:hover { background: #444; color: #f9f9f9;
}
.second-demo li a { width: 100%; display: block;
}
.third-demo li { width: 170px; padding: 0 15px;
}
.third-demo li a { display: block; width: 100%;
}
.fourth-demo li a { width: auto; padding: 0 15px; display: block;
}
code { font-family: Monaco, 'Courier New', monospace; font-size: .8125em;
}
em { font-style: italic; }
.correct { color: #2ec740; }
.incorrect { color: #bd1717; }
The Importance of Proper Navigational CSS - Script Codes
The Importance of Proper Navigational CSS - Script Codes
Home Page Home
Developer Chris Burnell
Username chrisburnell
Uploaded September 16, 2022
Rating 3
Size 3,165 Kb
Views 34,408
Do you need developer help for The Importance of Proper Navigational CSS?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Chris Burnell (chrisburnell) Script Codes
Create amazing sales emails with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!