Chrome bug when 'div' inside an anchor tag in HTML

 Chrome behaved strangely when I put a 'div' inside an anchor ('a') tag.


Chrome put the 'div' after the anchor tag rather than inside it.


I fixed this by changing the 'div' tags to 'span' tags and set the 'span' tags to 'display: inline-block'.


However, it seems the HTML5 specification says that you can put an anchor tag around most tags.


There are discussions about this on 'stackoverflow.com'.


My 'div' contains other 'divs'. The anchor tag is inside some complex HTML - a simpler example worked fine.


I am using an old version of Chrome: the last version on Windows7 from the start of 2024. 


(My local library has not upgraded from Windows7 yet. The library has instead installed a more recent version of Firefox. Sadly some websites like 'Outlook' and 'Pinterest' do not completely work with the old version of Chrome)


The 'divs' are for an RSS icon made in CSS from:


    'codepen.io/dazulu/pen/nwppvr'


I put the RSS icon alongside a few other website symbols for Facebook, X and so on.


It would be best to use an SVG, but my very old Konqueror browser at home does not show SVG's in an HTML page. Also I can learn more about CSS.


I now need to use 'currentTarget' on a 'click' event on the anchor tag because if I click on a child 'div' and the event bubbles up to the anchor then the 'target' property is the child not the parent. I want the 'href' property on the parent so I can open the link in a new tab



There are more tips at: bbingo.xyz/techtips/




Comments

Popular posts from this blog

Steve Jobs quotes

Dark mode using 'invert' does not work on Firefox

U.S. government uses internet backdoors for surveillance