Right way to list image banners - image

I would like to ask if what is the right way to use 'ul'? will it be okay to use 'ul' to list some image banners? ex. i have 3 image banners with titles and all are floated left. I use to encounter this situation every time and the approach i came up with is the first markup using 'ul'.
Is it okay to use the markup below:
<section class="banners">
<ul>
<li>
<figure>
<a href="#">
<img src="" width="" height="" alt="" />
</a>
</figure>
title here
</li>
<li>
<figure>
<a href="#">
<img src="" width="" height="" alt="" />
</a>
</figure>
title here
</li>
<li>
<figure>
<a href="#">
<img src="" width="" height="" alt="" />
</a>
</figure>
title here
</li>
</ul>
</section>
or should I use:
<section class="banners">
<figure>
<a href="#">
<img src="" width="" height="" alt="" />
</a>
<figcaption>
title here
</figcaption>
</figure>
<figure>
<a href="#">
<img src="" width="" height="" alt="" />
</a>
<figcaption>
title here
</figcaption>
</figure>
<figure>
<a href="#">
<img src="" width="" height="" alt="" />
</a>
<figcaption>
title here
</figcaption>
</figure>
</section>
Do they both represent semantic coding?
This is the sample of the image banner

Since the HTML5 spec is so mercurial and the semantics don't seem to play a major role practically, it's hard to say. However, based on your image, it looks like this is a navigation section. As such, you would want to section it with <nav>.
<ul> spec: http://www.w3.org/TR/html5/grouping-content.html#the-ul-element
<figure> spec: http://www.w3.org/TR/html5/grouping-content.html#the-figure-element
I don't think that these are much help. They are both used for grouping content. The order does not matter for <ul>.
From what I've read, it seems to me that the purpose of <figure> is for annotations of a document -- describing related images, etc. The spec specifically says that these could be moved elsewhere, like an appendix, but that doesn't seem to apply to your situation.
I don't think that <figure> is appropriate here. Instead, use <nav>. You can use the <ul> for styling if you need -- it doesn't provide much semantic meaning (just a somewhat generic grouping content element).

Related

how to add image logo in nav-bar bootstrap 5?

i want to add image logo in nav-bar using bootstrap 5
<a class="navbar-brand" href="#">
<img src="demo-logo.png" alt="logo" >demo-logo
</a>
i'm using this code by many way but, it didn't working
<nav class="navbar navbar-light bg-light">
<div class="container">
<a class="navbar-brand" href="#">
<img src="/docs/5.0/assets/brand/bootstrap-logo.svg" alt="" width="30" height="24">
</a>
</div>
</nav>
Check This

Match tag inside tag using bash

I have this html
<article class="article column large-12 small-12 article--nyheter">
<a class="article__link" href="/nyheter/14343208/">
<div class="article__content">
<h2 class="article__title t54 tm24">Person har falt ned bratt terreng - luftambulanse er på vei</h2>
</div>
</a>
</article>
<article class="article column large-6 small-6 article--nyheter">
<a class="article__link" href="/nyheter/14341466/">
<figure class="image image__responsive" style="padding-bottom:42.075%;">
<img class="image__img lazyload" itemprop="image" title="" alt="" src="data:image/gif;base64,R0lGODlhEAAJAIAAAP///wAAACH5BAEAAAAALAAAAAAQAAkAAAIKhI+py+0Po5yUFQA7" />
</figure>
<div class="article__content">
<h2 class="article__title t34 tm24">Vil styrke innsatsen mot vold i nære relasjoner</h2>
</div>
</a>
</article>
The thing is that I want to get only those html tags, in this case article tags, which has a child img tag inside them.
I have this sed command
sed -n '/<article class.*article--nyheter/,/<\/article>/p' onlyArticlesWithOutSpace.html > test.html
Now what I am trying ti achieve is to get only those article tags which has img tag inside them.
Output I want would be this
<article class="article column large-6 small-6 article--nyheter">
<a class="article__link" href="/nyheter/14341466/">
<figure class="image image__responsive" style="padding-bottom:42.075%;">
<img class="image__img lazyload" itemprop="image" title="" alt="" src="data:image/gif;base64,R0lGODlhEAAJAIAAAP///wAAACH5BAEAAAAALAAAAAAQAAkAAAIKhI+py+0Po5yUFQA7" />
I cannot use any xml/html parser. Just looking to use sed, grep, awk etc.
</figure>
<div class="article__content">
<h2 class="article__title t34 tm24">Vil styrke innsatsen mot vold i nære relasjoner</h2>
</div>
</a>
</article>
Care: parsing XML using sed is a wrong good idea!
Thanks to Cyrus's comment for pointing to good reference.
Anyway, U could try this:
sed -ne '/<article/{ :a; N; /<\/article/ ! ba ; /<img/p ; }'

Get html tags and loop over them using bash

I have this input file
<article class="article column large-12 small-12 article--nyheter">
<a class="article__link" href="/nyheter/14341175/">
<figure class="image image__responsive" style="padding-bottom:42.075%;">
<img class="image__img lazyload" itemprop="image" title="" alt="" />
</figure>
<div class="article__content">
<h2 class="article__title t54 tm24">Mann savnet etter å ha blitt angrepet av to haier</h2>
</div>
</a>
</article>
<article class="article column large-6 small-6 article--nyheter">
<a class="article__link" href="/nyheter/14315514/">
<figure class="image image__responsive" style="padding-bottom:42.075%;">
<img class="image__img lazyload" itemprop="image" title="" alt="" />
</figure>
<div class="article__content">
<h2 class="article__title t34 tm24">Flere blir 100 år – Tordis (102) tror hun
vet noe av oppskriften</h2>
</div>
</a>
</article>
<article class="article column large-6 small-6 article--nyheter">
<a class="article__link" href="/nyheter/14336393/">
<figure class="image image__responsive" style="padding-bottom:42.075%;">
<img class="image__img lazyload" itemprop="image" title="" alt="" />
</figure>
<div class="article__content">
<h2 class="article__title t34 tm24">To menn i 30-Ã¥rene tiltalt for grov voldtekt av mann tidlig
i 20-Ã¥rene</h2>
</div>
</a>
</article>
These are three article tags. I want to make three files from these three article tags having info from them. Example of the output would be
news1.txt
http://example.no/news/123456789/af31/4928 // link (a tag)
Franzens djevelsk gode forstadsfabel // name (h2 tag)
http://imgs.example.no/pics/0291817572384234.jpg // image (img tag)
2021-10-27 10:45 // date (when the file was created)
Can this be done in bash using sed, awk?

Bootstrap image resize for small screen, not working

I am trying to resize image using Bootstrap. I have a sufficiently large logo, for large screens & resolutions. Apparently, the image should resize well in all resolutions (small & big resolutions).
I have used the Bootstrap’s .img-responsive class for making images responsive. As is evident, image shows fine in large resolutions, but the image should become small in smaller resolutions. The problem is that - image is not getting smaller in smaller resolutions.
Any help would be highly appreciated.
<BODY>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header col-xs-3 col-md-3">
<a class="navbar-brand" href="#">
<img class="img-responsive" src="someimage.png">
</a>
</div>
<div class="col-xs-9 col-md-9">
<ul class="nav navbar-nav navbar-right">
<li><img class="img-responsive" src="A1.png"></li>
<li><img class="img-responsive" src="A2.png"></li>
</ul>
</div>
</div>
</nav>
</BODY>
I think the root of your problem is that you are expecting that the .img-responsive class will automatically make your images smaller for smaller screens, and this isn't exactly how it works.
It actually applies max-width: 100%; and height: auto; to the image, i.e. if it's a wide image it won't be wider than its parent. http://getbootstrap.com/css/#images
Hope this helps
With bootstrap 4 there are display utilities which can be used to render different images for different viewport,
e.g.
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header col-xs-3 col-md-3">
<a class="navbar-brand" href="#">
<img class="d-none d-sm-block" src="someimage.png"><!-- Image to show on screens from small to extra large -->
<img class="d-sm-none" src="someimagesmaller.png"><!-- Image to show on extra small screen (mobile portrait) -->
</a>
</div>
</div>
</nav>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header col-xs-3 col-md-3">
<a class="navbar-brand" href="#">
<img class="hidden-xs" src="someimage.png">
<img class="visible-xs" src="someimagesmaller.png">
</a>
</div>
<div class="col-xs-9 col-md-9">
<ul class="nav navbar-nav navbar-right">
<li><a href="#"><img class="hidden-xs" src="A1.png">
<img class="visible-xs" src="A1smaller.png"></a></li>
<li><img class="img-responsive" src="A2.png"> </li>
</ul>
</div>
</div>
</nav> `
In Bootstrap version 4 class ".img-responsive" has been changed to ".img-fluid".
use the class="img-responsive" and it will shrink the image when you open in mobile or other device using bootstrap css. but for u its not working can u check the correct links you added in the headers.

How to code anchor tags as block element to contain other block elements

I am experiencing the same problem described in this thread. I'm wondering if there are other ways to achieve the same result and avoid this issue.
Apparently Firefox has issues with anchor tags containing block elements even when the display CSS property of the anchor tag is set to "block". The effect that I am trying to achieve is to have a the complete block click-able instead of the the text in the block. It also allows to apply the hover state to the whole block instead of the link part.
Can anyone suggest a technique
EDIT:
This is what I intend to show:
<div class="entry ">
<a class="link" href="/topics/34/steroids">
<h2>Some Text</h2>
<div class="info">
<div class="tag-visualization">
<div style="width: 67%;" class="guage"></div>
</div>
<ul class="stats">
<li>
<strong>0</strong><br>FOLLOWERS
</li>
<li>
<strong>2</strong><br>ANSWERS
</li>
<li>
<strong>2</strong><br>QUESTIONS
</li>
</ul>
</div>
</a>
</div>
This is what firefox renders:
<div class="entry ">
<a class="link" href="/topics/45/diet">
</a><h2><a _moz-rs-heading="" class="link" href="/topi/45/diet">sometext</a></h2>
<a class="link" href="/topics/45/diet"> </a><div class="info">
<a class="link" href="/topics/45/diet">
</a><div class="tag-visualization">
<a class="link" href="/topics/45/diet"> </a><div style="width: 67%;" class="guage"></div>
<a class="link" href="/topics/45/diet"> </a></div>
<a class="link" href="/topics/45/diet"> </a><ul class="stats">
<a class="link" href="/topics/45/diet"> </a><li>
<a class="link" href="/topics/45/diet"> <strong>0</strong><br>FOLLOWERS
</a></li>
<a class="link" href="/topics/45/diet"> </a><li>
<a class="link" href="/topics/45/diet"> <strong>2</strong><br>ANSWERS
</a></li>
<a class="link" href="/topics/45/diet"> </a><li>
<a class="link" href="/topics/45/diet"> <strong>2</strong><br>QUESTIONS
</a></li>
<a class="link" href="/topics/45/diet"> </a></ul>
<a class="link" href="/topics/45/diet"> </a></div>
<a class="link" href="/topics/45/diet"> </a>
</div>
When I would normally need a <div> inside an <a>, I use a <span> instead with display:block;. Doesn't break the layout in Firefox with the aforementioned bug and behaves exactly as a <div> does.
Just use an anchor with display set to block. If you are saying what I think you are saying then I was in the same situation a while back - wanting to place images within a block anchor, without the underline under the image. This was resolved by applying float: left; to the img tag.
For example:
<img style="float: left" src="calendar.gif" />Events
If you place this inside several li tags then you can get a very simple menu with clickable blocks.
If this is not what you want then please give an example of where you would want a block element in a block anchor - I dont understand where you would want such a thing.
Richard
In Bootstrap, they seem to add the rule position: relative to the anchor tags inside of the .nav class. If you add this rule to the anchor tag, it should act as a clickable hyperlink.
I just tried it, and it seems to work on all modern browsers! I haven't tested this in any legacy browsers yet.

Resources