Is a label for an hidden field 508 compliant? - html

I have the following Struts2 code which generates a list of shippers. It only shows after the user choses the type of shipment (the hidden class is removed by JavaScript).
<div class ="showIfNotOther hidden">
<div class="row">
<div class="col-xs-12 rowsecthead" id="shipperInfoHeader"><s:text name="shipperInfo"/></div>
</div>
<s:iterator value="chosenShipperViewList" status="status">
<div class="row small-line-height">
<div class="col-sm-2 col-xs-12 "><label for='<s:property value="%{'deleteShipper'+#status.index}" />' class="pull-right"><s:text name="deleteShipperInfo"></s:text>:</label></div>
<div class="col-sm-3 col-xs-12 text-left">
<s:url var="deleteLink" action="shipment_deleteShipperFromChosenShipperViewList"></s:url>
<s:a id="%{'deleteShipper'+#status.index}" href="%{deleteLink}"> <img src="/llr/theme/delete.gif" width="16" height="16" alt="Map Red X" ></s:a>
</div>
<hr>
</div>
</s:iterator>
The Struts2 code generates the following HTML which has each "Delete Shipper Info:" label associated with each <a> element by an id (deleteShipper0, deleteShipper1, etc.) which is what I understand is required to be 508 compliant.
<div class ="showIfNotOther hidden">
<div class="row">
<div class="col-xs-12 rowsecthead" id="shipperInfoHeader">Shipper Information</div>
</div>
<div class="row small-line-height">
<div class="col-sm-2 col-xs-12 "><label for='deleteShipper0' class="pull-right">Delete Shipper Info:</label></div>
<div class="col-sm-3 col-xs-12 text-left">
<a id="deleteShipper0" href="/llr/shipment_deleteShipperFromChosenShipperViewList.action?organizationName=Mercy"><img src="/llr/theme/delete.gif" width="16" height="16" alt="Map Red X" ></a>
</div>
<hr>
</div>
<div class="row small-line-height">
<div class="col-sm-2 col-xs-12 "><label for='deleteShipper1' class="pull-right">Delete Shipper Info:</label></div>
<div class="col-sm-3 col-xs-12 text-left">
<a id="deleteShipper1" href="/llr/shipment_deleteShipperFromChosenShipperViewList.action?organizationName=Nuclear"><img src="/llr/theme/delete.gif" width="16" height="16" alt="Map Red X" ></a>
</div>
<hr>
</div>
When I put the HTML in the W3C Markup Validation Service I get the error
The for attribute of the label element must refer to a non-hidden form control.
Is the HTML really not compliant (and if it isn't, how do I fix it), or is this just a bug in the W3C Markup Validation Service?

As defined by the W3 definition of a label:
The label element represents a caption for a form control.
You are currently using a label tag for a link, not for a form control, which is your first error.
And yes, it is right:
The for attribute of the label element must refer to a non-hidden form control.
When navigating with a screenreader you have to be able to go from the label to the form control. But in your case, it seems that both your label and your future form control (once you will have replaced the link with a form control) will be in the same hidden div. So you won't have to care about such remark.
But I think that using a form control will remove this comment from the W3 validator as it does not handle CSS.

Related

How could I change the appearance of the HTML view?

Consider the below Angular 2 Template code :
<div *ngIf="artist">
<header class="artist-header">
<div *ngIf="artist.images.length > 0">
<img class="artist-thumb img-circle" src="{{artist.images[0].url}}">
</div>
<h1>{{artist.name}}</h1>
<p *ngIf="artist.genres.length > 0">
Genres : <span *ngFor="let genre of artist.genres">{{genre}}</span>
</p>
</header>
<div class="artist-albums">
<div class="row">
<div class="col-md-3" *ngFor="let album of albums">
<div class="card bg-faded card-body album">
<div *ngIf="album.images.length > 0">
<img class="album-thumb img-thumbnail" src="{{album.images[0].url}}">
<h4>{{album.name}}</h4>
<a class="btn btn-default btn-block" routerLink="/album/{{album.id}}">Album Details</a>
</div>
</div>
</div>
</div>
</div>
</div>
In spite of applying class="col-md-3", all divs are appearing in a new line vertically. Below is the image shown. I want that 3 div should appear horizontally in one line. What's need to be changed within the above code?
If the whole code you posted is looped to display all these images, each of the col-md-3 is in a seperate row div, which creates a linebreak each time. So try to make the loop inside that row div, only for the col-md-3 elements.
Add the other bootstrap options to the div:
col-lg-3 col-md-3 col-sm-3 col-xs-3
Be sure that you do not have any margins or haven't override the default width from bootstrap using "!important" flag.
Try to see the live CSS using "inspect element" option in your browser and try to change the data there so you can figure out what is going on.

How to add 'routerLink' dynamically?

I'm using Angular 4, and i want to append some static html that is comming from database. Content have some 'anchor tag' which is hold routerLink attribute. When i show in template via [innerHTML], it's removing 'routeroutlet' attribute from anchor tag. How it is possible to add 'routerLink'? Which is work properly for navigation page?
My content is given below, which is comming from database:
<div class="row banner-item">
<div class="col-md-9 col-sm-9 col-xs-12">
<img alt="banner-image" class="banner-image" src="assets/images/banner-img1.jpg"/>
</div>
<div class="col-md-3 col-sm-3 col-xs-12 banner-image">
<img alt="banner-image" class="banner-image" src="assets/images/banner-img3.jpg"/>
<img alt="banner-image" class="banner-image" src="assets/images/banner-img2.jpg"/>
</div>
</div>

how to add html button on last index with token in the text box?

I want to add in the last index html button with token.
for example i have the three type token like test1,test2,test3 so in my text box show 3 token then i want to add button after "test3" token in the text box.
below my html code.
<div class="col-lg-10 col-md-10 col-sm-12 col-xs-12">
<div class="tokenfield form-control">
<div class="token">
<span class="token-label" style="max-width: 664px;">test1</span>x
<span class="token-label" style="max-width: 664px;">test2</span>x
<span class="token-label" style="max-width: 664px;">test3</span>x
</div>
</div>
<input type="text" id="txttoken" class="full-width palintxtbx instagrowth_tokens" placeholder="entre" />
</div>

Picture will not appear

I am brand new to coding and have not been able to determine why two seemingly identical pieces of code do not work the same. This exercise involves simply making a picture appear on a web page. Easy enough, but I do not see why the same code only works one out of two times.
This code works:
<div class="col-sm-6">
<div class="well text-center">
<div>
img class="img-responsive" src="http://pre10.deviantart.net/1d23/th/pre/i/2013/070/1/e/grumpy_cat_by_bwcopy-d5xod2v.jpg"
</div>
While this code does not:
<div class="col-sm-6">
<div class="well text-center">
<div>
img class="img-responsive" src="https://img.buzzfeed.com/buzzfeed-static/static/2015-04/21/16/enhanced/webdr05/enhanced-31550-1429646952-7.jpg"
</div>
I checked the source for the non-working photo and it is valid. (Check it yourself if you like ultra-cute puppies).
What am I not seeing? (besides the puppy picture, obviously).
Thanks.
You are not using the img tag, you are just writing plain text.
Change to this (notice the brackets):
<img class="img-responsive" src="http://pre10.deviantart.net/1d23/th/pre/i/2013/070/1/e/grumpy_cat_by_bwcopy-d5xod2v.jpg" />
First and 2nd code snippets look the same, no reason either of them should work.
try this
<div class="col-sm-6">
<div class="well text-center">
<div>
<img class="img-responsive" src="http://pre10.deviantart.net/1d23/th/pre/i/2013/070/1/e/grumpy_cat_by_bwcopy-d5xod2v.jpg">
</div>
or this:
<div class="col-sm-6">
<div class="well text-center">
<div>
<img class="img-responsive" src="https://img.buzzfeed.com/buzzfeed-static/static/2015-04/21/16/enhanced/webdr05/enhanced-31550-1429646952-7.jpg">
</div>

insert an element after a number of ng-repeat iteration

Is there a way to avoid such use of ng-repeat.
To fix the issue ,I used two ng-repeat using the option limitTo to display each 3 element separately.
What I want to do is ,to insert my elements and after each 3 elements ,So I add
<div class="row"> </div>
Below is my code:
<div class="row">
<div class="col-md-10 col-md-offset-1">
<div class="row l-b-margin">
<div class="col-md-4" ng-repeat="name in Courses|limitTo:3">
<div class="well well-white">
<img alt="R Programming" class="center-block l-b-margin"
height="100" ng-src="{{name.logo}}" width="100" />
<h6 style="text-align: center; color: #516979; font-size: 21px">{{name.name}}</h6>
<p class="text-space l-b-margin">Write your first code here</p>
<a class="rounded-button cta-border-button center-block m-button"
href="courses/introduction-to-r">Start Course</a>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4" ng-repeat="name in Courses|limitTo:-3">
<div class="well well-white">
<img alt="Data Manipulation" class="center-block l-b-margin"
height="100" ng-src="{{name.logo}}" width="100" />
<h6 style="text-align: center; color: #516979; font-size: 21px">{{name.name}}</h6>
<p class="text-space l-b-margin">Write your first code here</p>
<a class="rounded-button cta-border-button center-block m-button"
href="courses/data-table-data-manipulation-r-tutorial">Start
Course</a>
</div>
</div>
</div>
</div>
</div>
The simple way to do is use ($index+1)%3==0 with ng-if and put the below element at the end of ng-repeat.
<div class="row" ng-if="($index+1)%3==0"> </div>
Plunker
Hope it helps :)
What you're seem to be doing is trying to prevent this situation from happening: (some blocks shifts to the next row if not all have equal heights)
If that's the case you can (and should;) ) fix it via simple css: (just add a custom class to the div your iterating over)
.my-block:nth-child(3n+1) {
clear: left;
}