link target blank code example

Example 1: where to use .target command in html

<a target="_blank" href="">

Example 2: link_to target blank

link_to "External link", "http://www.rubyonrails.org/", target: "_blank", rel: "nofollow"
# => <a href="http://www.rubyonrails.org/" target="_blank" rel="nofollow">External link</a>

Example 3: href target new window

target="_blank"

Example 4: target _blank on a link_to

link_to "allrecipes", "http://www.allrecipes.com", target: "_blank", class: "p-12 rounded-lg font-bold"

Example 5: link_to target blank

link_to(body, url, html_options = {})
  # url is a String; you can use URL helpers like
  # posts_path

link_to(body, url_options = {}, html_options = {})
  # url_options, except :method, is passed to url_for

link_to(options = {}, html_options = {}) do
  # name
end

link_to(url, html_options = {}) do
  # name
end

Tags:

Html Example