view raw
SoftTimur SoftTimur - 10 months ago 36
HTML Question

Adding an onclick event to a text without breaking the line

I need to add an

event (rather than a hyperlink) to a text. But using
tag breaks the line:

enter image description here

Here is the code and JSBin. Could anyone help?

<!DOCTYPE html>
See our <p onclick="openWindow()" style="cursor: pointer; color:blue">support page</p> and other things...
function openWindow() {"");


Actually you should use <a>.

You can still use onclick. Just give it href="#"

See our <a onclick="openWindow();" href="#">support page</a> and other things...
  1. Semantically correct

  2. Saves the styling overhead of the <span>

  3. If you globally style <a> elements in your page, it will get the style too.

Side Note

If your only intention is to open the link in a new tab (as in your example) then use target instead of JS

See our <a target="_blank" href="">support page</a> and other things...