Skip to main content

Frontend Web Dev

Good Practices

  • Divs should never be clickable elements - Not accessible, don't work with screen readers, don't work with keyboard actions like tab, return or space.

  • Button

    • comes with built-in styling, usually a bad thing. (all: unset) can come in handy.
    • inside of a form, the onClick will fire a submit
  • Buttons should not be used for navigation.

    • Not crawlable for SEO
    • "Open link in new tab", middle clicks will cause issues.
    • Many current UI libraries render an anchor tag if a href property is passed in -> can define your own button component to do the same thing.

CSS

// overrides all default rules
button {
all: unset;
}

Links

Button vs Anchor tags -