Is javascript <div> connection acceptable?

I want to link the whole <div>, but CSS2 does not support adding href to a div (or span, for that matter). My solution is to use the onClick property to add the link. Is this acceptable for modern browsers?

Code example:

<div class="frommage_box" id="about_frommage" onclick="location.href='#';">
            <div class="frommage_textbox" id="ft_1"><p>who is Hawk Design?</p></div>

My test page is at http://www.designbyhawk.com/pixel . Updated daily.

Thanks for the help.

+3
source share
6 answers

You do not need to do this. There is a completely simple and standardized way to do this.

. a , display: block CSS.

. ( Javascript!). div , . p a.

+14

click <div> JavaScript.

, <a>.

+1

, SEO.

, <a>, div? ( : ..)

+1

( IE6). , , , . div. "a" .

0

HTML:

<div class='frommage_box'>
    <a href='location.html'>CONTENT GOES HERE</a>
</div>

CSS

.frommage_box a{
    display:block;
    height:100%;
}

100% . 100%. yoru.

0

, , , CSS :

a {
   display: block;
   padding: 10px;
   width: 200px;
   height: 50px;
}
0

Source: https://habr.com/ru/post/1792359/


All Articles