css - Why do you put a display:block on an "a" tag that is inside a list? -


i trying understand image sprites on css, , 1 line of code looks this.

#navlist li, #navlist a{height:44px;display:block;} 

i wondering effect display:block has on "a", know "a" tag since link won't work if removed "a" , conversely if removed "display:block", i'm wondering why should "display:block".

the w3schools explanation display:block fallow

the element displayed block-level element (like paragraphs , headers) , can check display behavior here

practically use display:block in 4 situations

  1. element doesn't contains content, need show fix size block. eg: link background image no text between open , close anchor tags.
  2. element need show in fix size ignore auto size according content.
  3. there set of elements , each should display in each line (one element per line).
  4. to implement show hide can use diaply:none , display:block

but link functionality doesn't have relationship display or css, link showld work interdependently, css wrote anchor tag, style link.

here more details display https://developer.mozilla.org/en-us/docs/web/css/display


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -