Do borders, that visually group related content, have a contrast requirement? - css

I cannot find existing accessibility requirements for the borders of content that is 'loosely related' or visually grouped into 'cards'. Is there one?
For users that are truly blind, the borders around cards need not have a border, but I would assume that for users with slight visual impairments, or for users with cognitive disabilities, the content may be easier to understand if they can see the border around the card?
How about accordions?: They usually have a'decorative' border around their headers, even thought this is not required, and therefor probably do not need to adhere to minimal contrasting colors?
Would the border be decorative or meaningful/informative in these situations?
I have coded the following situation: an information page that shows cards that contain a Heading with a title/aria-label and a paragraph that explains where the user will navigate to - but all cards have a light grey border of 1 pixel, (a border that does not pass the contrast-requirement).
Is this sufficient for AA-level requirements?
Codepen here: codepen.io/jirosworld/pen/XWBwbXK
HTML:
<main class="container">
<div class="grid">
<div class="grid__main">
<h1 class="h1">Government support </h1>
<div class="card-container card-container--small">
<div class="card">
<div class="card__body">
<h2 class="h2">
<a href="#" class="link" aria-label="energy-allowance" title="energy-allowance">
<span class="link__text">Energy allowance</span>
</a>
</h2>
<p class="p">Energy prices have risen sharply. Many households find it difficult to pay the bill. The municipality compensates low-income households. The government makes extra money available for this</p>
<a href="#" class="button button--icon button--transparent" aria-label="energy-allowance" title="energy-allowance">
<span aria-hidden="true" class="material-icons ">→</span>
</a>
</div>
</div>
<div class="card">
<div class="card__body">
<h2 class="h2">
<a href="#" class="link" aria-label="Form House" title="Form House">
<span class="link__text">Help with forms</span>
</a>
</h2>
<p class="p">Do you have questions about administration, forms, laws and regulations or finances? Come visit our "Form House"</p>
<a href="#" class="button button--icon button--transparent" aria-label="Form House" title="Form House">
<span aria-hidden="true" class="material-icons ">→</span>
</a>
</div>
</div>
</div>
</div>
</div>
</main>
<p class="default-content">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum at magna eu velit iaculis tempor sit amet at enim.</p>
CSS:
body {
padding: 1em;
font-family: sans-serif;
color: #4b4b4b;
}
a:link {
display:block;
color: #4b4b4b;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a.button {
color: rgb(0,166,199);
text-align: right;
font-size:2em;
}
a:hover.button {
padding-top: 2px;
text-decoration: none;
}
h2 {
font-size: 20px;
}
.grid {
display: flex;
flex-direction: column;
gap: var(--gutter-width);
position: relative;
width: 100%;
}
.card-container {
display: grid;
gap: 32px;
grid-template-columns: repeat(2,1fr);
}
element.style {
}
.card {
background-color: #fff;
border: 1px solid #d2d2d2;
border-radius: 3px;
box-sizing: border-box;
display: flex;
flex-direction: column;
position: relative;
text-decoration: none;
padding: 16px;
margin-bottom: 1em;
}
.default-content {
max-width: 900px;
}

WCAG does not require you to have a border around the grouped elements. However, from a visual UX perspective, it can be very helpful.
If you do have a visual grouping around the elements, then you also have to convey that grouping to assistive technology. You can do that semantically by having a <fieldset>/<legend>. You can style it however you want and even hide the <legend> so it's not visible but still allow the screen reader to announce it.
<fieldset aria-labelledby="foo">
<legend style="display: none;" id="foo">hello</legend>
<!-- your tiles -->
</fieldset>
But hiding the legend kind of defeats the purpose of having it. If you go that route, you might as well leave it off and just put the aria-label on the <fieldset>.
<fieldset aria-label="hello">
<!-- your tiles -->
</fieldset>
Or you can use ARIA attributes to group them. Using semantic HTML is the first preference but ARIA will also work.
<div role="group" aria-label="hello">
<!-- your tiles -->
</div>
Using your original code, the <div class="card"> could have the group role.
<div class="card" role="group" aria-label="???">
I'm not sure what the label should be. Perhaps the link name?
<div class="card" role="group" aria-labelledby="link1">
<div class="card__body">
<h2 class="h2">
<a id="link1" href="#" class="link" aria-label="energy-allowance" title="energy-allowance">
<span class="link__text">Energy allowance</span>
</a>
</h2>
As far as the color of your border, there aren't any WCAG requirements for the contrast. 1.4.11 Non-text Contrast comes close but that requirement is for "Interface Components" and "Graphical Objects". Your tile might contain "Interface Components" (such as a link) but the tile itself is not an "Interface Component" so 1.4.11 does not apply. That doesn't mean you shouldn't try to have better contrast, but it's not required by WCAG.
As a side note, you have a few oddities in your example code. Your first link, "Energy allowance" has an aria-label="energy-allowance". There's no need for an aria-label since the label of the link is the text inside the link. There's also no need for a tooltip, the title attribute, if it's the same text as the link.
The right arrow link in the tile does need an aria-label since you're hiding the → from assistive technology (aria-hidden="true"), so you're doing that correctly, although the aria-label should be "energy allowance" instead of "energy-allowance".
The second tile has the same problem plus a new problem, WCAG 2.5.3 Label in Name since your aria-label ("Form House") does not match the visual text in the link ("Help with forms"). Just remove the aria-label and the 2.5.3 issue goes away.

Related

CSS row-fluid not responsive

I'm a beginner in html/css and I'm trying to create something that will go into a page of a platform called Chronus. The idea is for users to be able to click on one of the four choices which will take them to the relevant section in the platform so that they don't have keep 'going back' (a sort of nav, but not really). I've used 'row fluid' as per the code below. I also attach an image to show you how it looks in a desktop/laptop. The problem is, as the width of the device decreases, the div that all the links are in does not increase in height, so the second two links are cut off (also image attached).
<div class="row-fluid" style="background-color: #DEEBF9; color: #094183;">
<div class="footerlinks">
<div class="span3">
<p>Before the match</p>
<i class="fa fa-arrow-right"></i></div>
<div class="span3">
<p>Career resources</p>
<i class="fa fa-arrow-right"></i></div>
<div class="span3">
<p>The mentoring partnership</p>
<i class="fa fa-arrow-right"></i></div>
<div class="span3">
<p>Partnership wrap up</p>
<i class="fa fa-arrow-right"></i></div>
</div>
</div>
<style>
.footerlinks {
text-align:center;
height: 160px;
vertical-align: middle;
padding: 40px;
font-family: ARIAL;
font-size: 20px;
}
</style>
links in laptop/desktop
links in narrow device
Would anyone be able to suggest a solution for this please? Thank you very much in advance.
Remove the height from .footerlinks. The reason it is happening is that when you see it from a narrow device, your content is more than 160px.
.footerlinks {
text-align:center;
vertical-align: middle;
padding: 40px;
font-family: ARIAL;
font-size: 20px;
}

Pseudo class after & before only display when with position absolute [duplicate]

This question already has answers here:
Why doesn't width/height work with non positioned pseudo elements?
(1 answer)
Percentage Height HTML 5/CSS
(7 answers)
Closed 2 years ago.
I use mixin SASS to called background because I will use this code often. I will use the background mixin to create pseudo-class after and before.
This the code of the background mixin:
#mixin background($height: 10%){
content: '';
position: absolute;
width: 100%;
height: $height;
left: 0;
background-size: 100% 100%;
background-repeat: no-repeat;
}
I tried to add some curves using pseudo-class after and before elements. But the curve does not appear if the position isn't absolute. I tried the other value and it does not work. I read some questions about this topic and someone said that it's because the absolute position behaves as a block-level element. Then I tried using display block and inline-block without using the position property and it does not work. I think it's a different case.
This is the code of my pseudo clas:
.users::after {
#include background(25%);
bottom: -100px;
background: url(../images/bg-section-bottom-mobile-2.svg) no-repeat;
}
.users::before {
#include background(25%);
top: -100px;
background: url(../images/bg-section-top-mobile-2.svg) no-repeat;
}
This is the deploy file in vercel
This is the snipset, i don't know how to add picture file. And this is not the full code, just the part I asked about
main .grow, main .conversations, main .users {
text-align: center;
padding: 30px;
}
main .grow img, main .conversations img, main .users img {
width: 80%;
}
main .grow h3, main .conversations h3, main .users h3 {
margin-top: 40px;
}
main .grow p, main .conversations p, main .users p {
margin-top: 20px;
}
main .users, main .grow {
background-color: #f5faff;
margin: 150px 0px 150px 0px;
position: relative;
}
main .grow::after {
content: '';
position: absolute;
width: 100%;
height: 25%;
left: 0;
background-size: 100% 100%;
background-repeat: no-repeat;
bottom: -100px;
background: url(../images/bg-section-bottom-mobile-1.svg) no-repeat;
}
main .grow::before {
content: '';
position: absolute;
width: 100%;
height: 25%;
left: 0;
background-size: 100% 100%;
background-repeat: no-repeat;
top: -100px;
background: url(../images/bg-section-top-mobile-1.svg) no-repeat;
}
<body>
<!-- header -->
<div class="header">
<div class="header__logo">
<img src="images/logo.svg" alt="logo">
</div>
<button class="header__btn">Try it free</button>
</div>
<!-- section -->
<div class="starter">
<h2 class="starter__title">Build The Community Your Fans Will Love</h2>
<div class="starter__description">Huddle re-imagines the way we build communities. You have a voice, but so does
your audience. Create connections with your users as you engage in genuine discussion.</div>
<button class="starter__btn">Get Started For Free</button>
<img class="starter__illustration" src="images/screen-mockups.svg" alt="screen-mockups">
</div>
<!-- main -->
<main>
<div class="count">
<div class="count__community">
<img src="images/icon-communities.svg" alt="communities">
<h1>1.4k+</h1>
<p>Communities Formed</p>
</div>
<div class="count__message">
<img src="images/icon-messages.svg" alt="messages">
<h1>2.7m+</h1>
<p>Message Sent</p>
</div>
</div>
<div class="grow">
<img src="images/illustration-grow-together.svg" alt="illustration-grow-together">
<div class="grow__container">
<h3>Grow Together</h3>
<p>Generate meaningful discussions with your audience and build a strong, loyal community.
Think of the insightful conversations you miss out on with a feedback form.</p>
</div>
</div>
<div class="conversations">
<img src="images/illustration-flowing-conversation.svg" alt="illustration-flowing">
<div class="conversations__container">
<h3>Flowing Conversation</h3>
<p>You wouldn't paginate a conversation in real life, so why do it online? Our threads have
just-in-time loading for a more natural flow.</p>
</div>
</div>
<div class="users">
<img src="images/illustration-your-users.svg" alt="illustration-users">
<div class="users__container">
<h3>Your Users</h3>
<p>It takes no time at all to integrate Huddle with your app's authentication solution. This means,
once signed in to your app, your users can start chatting immediately.</p>
</div>
</div>
<div class="action">
<h2 class="action__title">Ready To Build Your Community</h2>
<button class="action__btn">Get Started For Free</button>
</div>
</main>
<!-- footer -->
<footer class="footer">
<div class="footer__newsletter">
<h3>newsletter</h3>
<p>To recieve tips on how to grow your community, sign up to our weekly newsletter. We’ll never
send you spam or pass on your email address</p>
<form>
<input type="text" name="email">
<button type="submit">Subscribe</button>
</form>
</div>
<div class="footer__contact">
<div class="logo">
<img src="images/icon-messages.svg" alt="logo">
<h1>HADDLE</h1>
</div>
<p class="description">Lorem ipsum dolor sit amet consectetur adipisicing elit. Officia sequi culpa voluptates perferendis provident natus.</p>
<div class="phone">
<img src="images/icon-phone.svg" alt="phone">
<p>Phone: +1-543-123-4567</p>
</div>
<div class="email">
<img src="images/icon-email.svg" alt="email">
<p>example#huddle.com</p>
</div>
<div class="sosmed">
<div class="fb container">
<i class="fab fa-facebook-f"></i>
</div>
<div class="ig">
<i class="fab fa-instagram"></i>
</div>
<div class="twt container">
<i class="fab fa-twitter"></i>
</div>
</div>
</div>
</footer>
</body>
So the question is why my pseudo-class after and before only display when I use position absolute? Is it because I use mixin SASS?
I don't think so it is about using mixin SAAS because whether you use SAAS or not your code will turned into css codes. I want to ask you something, Why your ::before or ::after classes content is empty. Did you try to add some images in content? like content:url(...); Could you try it without absolute and relative. If it's not working, you should give more info about your code. And also this may give you some idea.

break in text using flexbox

I want my code to do what it is doing in this snippet but on my browser it's displayed as in the picture. I think it is flexbox causing this issue. Anyone has any idea why this could be and how to fix it?
I have checked whether if it is anything on other classes but this div is completely separate from the other divs and their classes
.activity-snippets {
display: flex;
}
.activity-post-link {
height: 215px;
width: 33.33333333%;
padding-right: 12px;
padding-left: 12px;
flex-grow: 0;
}
.activity-post-link img {
max-width: 100%;
}
.activity-post-link a {
text-decoration: none;
}
<div class="activity-snippets">
<div class="activity-post-link">
<a>
<img src="https://cdn.dribbble.com/users/476251/screenshots/2619255/attachments/523315/placeholder.png">
<h2>
My Girl's Cave for $55
</h2>
</a>
</div>
<div class="activity-post-link">
<a>
<img src="https://cdn.dribbble.com/users/476251/screenshots/2619255/attachments/523315/placeholder.png">
<h2>
Turning a French Door Into a Shower Wall.
</h2>
</a>
</div>
<div class="activity-post-link">
<a>
<img src="https://cdn.dribbble.com/users/476251/screenshots/2619255/attachments/523315/placeholder.png">
<h2>
LOVE SHELF
</h2>
</a>
</div>
</div>
If the snippet looks good but your actual full code doesn't, then there must be something else in your code preventing the text to wrap.
Looks like your flex items are being sized correctly but your text is overflowing. Check if there's some white-space: nowrap; being applied to those h2s anywhere in your full code.

HTML5 Multiple Images on the same line with Captions

I want to have multiple images on the same line with a caption below each image.
I can put images on the same line using the display:inline tag. When I add the figure tag, they are moved to different lines.
I tried multiple variation and can't get it to work.
Am I using the wrong tags for the job? I've seen this on other sites, but don't know how they do it.
CSS
section.products{
width: 100%;
padding:5px;
line-height:100%;
margin-top: 5px;
float: left;
text-align: center;
}
img.fans {
text-align: center;
max-width: 100%;
height: 50px;
width: 50px;
}
a {
color: #000000;
text-decoration: none;
font-weight: bold;
}
p {
text-align:center;
align: center;
}
figure {
display:center;
}
ul.fans li{
display: inline;
}
HTML
<section class="products">
<h1>Fans</h1>
<p>
<ul class="fans">
<li>
<a href="#">
<figure>
<img class="fans" src="images/shrouded.JPG" alt="Shrouded" style="Float"</img>
<figcaption>Shrouded</figcaption>
</figure>
</a>
</li>
<li>
<a href="#">
<figure>
<img class="fans" src="images/shallow_recess.JPG" alt="Shrouded" style="Float"</img>
<figcaption>Shallow Recess</figcaption>
</figure>
</a>
</li>
</ul>
</p>
</section>
You've got a couple things wrong.
You didn't close your image tags properly
you have in inline style of "float" which is not valid
This should help get you what you're looking for.
Css
ul.fans li {
display: inline-block;
}
figcaption {
text-align: center
}
Html
<section class="products">
<h1>Fans</h1>
<p>
<ul class="fans">
<li>
<a href="#">
<figure>
<img class="fans" src="http://placehold.it/300/300" alt="Shrouded"/>
<figcaption>Shrouded</figcaption>
</figure>
</a>
</li>
<li>
<a href="#">
<figure>
<img class="fans" src="http://placehold.it/300/300" alt="Shrouded" />
<figcaption>Shallow Recess</figcaption>
</figure>
</a>
</li>
</ul>
</p>
</section>
Codepen Example
with html 5 the proper way to put an image tag is like so
<img class="fans" src="images/shallow_recess.JPG" alt="Shrouded" />
You dont need a tag because you never finished opening the tag, it seems like you are mixing the old way of doing things like this
<img class="fans" src="images/shallow_recess.JPG" alt="Shrouded"></img>
display inline will make the li act as if they are a p tag or any other inline element.
The reason they are going to new lines when you add a figcaption is because figcaptions are display: block. block display types will always push items to the next line. with css you can change the display types of items like you did with the li elements.The figure tag is also a block element.
when you write html please always indent when there is nesting (an element inside of another one)
Also the style="Float" is not valid css. anything in between the "" will be css and it is called inline css. It is best to not have css inline because it can cause problems when trying to change the css the majority of elements later on.
you can add css in the top of your document with the style tag. like so
<style type="text/css">
ul.fans li {
display: inline;
}
</style>
You will want to correct the closing tag and get the css in the right spot, and make sure you do not do inline css (style="float:left;").
Since stated from the answer before that you probably don't need a list for this because lists are for breaking into new line, you will probably want to do something like this instead
<style type="text/css">
.fans li{
display: inline;
}
.fans .captioned-image {
display:inline-block;
width:200px;
}
.fans figure {
width: 200px;
display:block;
text-align:center;
}
img {
max-width:200px;
}
</style>
<section class="products">
<h1>Fans</h1>
<p>
<div class="fans">
<div class="captioned-image">
<a href="#">
<figure>
<img class="fans" src="images/shallow_recess.JPG" alt="Shrouded" style="" />
<figcaption>Shrouded</figcaption>
</figure>
</a>
</div>
<div class="captioned-image">
<a href="#">
<figure>
<img class="fans" src="images/shallow_recess.JPG" alt="Shrouded" style="" />
<figcaption>Shallow Recess</figcaption>
</figure>
</a>
</div>
</div>
</p>
</section>

How to clear the bottom of an image like clear left / right

Is there a way to clear the bottom of an image? I tried margin-bottom: 100%, and padding-bottom: 100%, but it is not working because I have more divs below which clears all.
I want to clear only the content of the image containing div.
HTML
<div class="contentpart">
<p>
<a href="http://www.s1waterbike.ro/wp-content/uploads/2013/07/contact-feat1.jpg">
<img class="alignnone size-medium wp-image-88" alt="contact-feat" src="http://www.s1waterbike.ro/wp-content/uploads/2013/07/contact-feat1-300x200.jpg" height="200" width="300">
</a>
</p>
the text....
</div>
<div class="contentpart">
The text.....
</div>
CSS
.contentpart img {
float: left;
clear: bottom;
}
Example of how the solution should look like
Based on your image, you can realize the layout by using the the following HTML:
<div class="contentpart">
<a href="#">
<img src="http://placehold.it/300x200">
</a>
Donec adipiscing, lorem non euismod venenatis...
</div>
and applying the following CSS rules:
.contentpart {
border: 1px dotted gray;
display: table;
}
.contentpart a {
display: table-cell;
vertical-align: top;
padding-right: 20px;
}
You can see the demo at: http://jsfiddle.net/audetwebdesign/wknjA/
How This Works
You can use CSS tables to get the text to stay in a single column without wrapping it in a block element.
Apply display: table to the parent block and display: table-cell to the a tag.
You can have some control over white space by applying some padding to the a element.

Resources