Search code examples
htmlcsssemantic-markup

Should I use a <p> tag or <div> tag here?


I feel rather silly actually asking this question as I am sure it will simply be opinion rather than correctness that will prevail.

But I have a "button" which is fixed to the lower right hand side of the screen which the user can click on to open the chat box.

Currently I just have this:

<div id="chatbtn">Sales help online</div>

I chose a <div> tag so that search engines don't think its a main text element. Should I have chosen a <p> tag to be semantically correct here?...or maybe even an <input type="button">

What do you think?


Solution

  • Button has its own tag actually:

    <button type="button" id="chatbtn">Sales help online</button>
    

    Default type is sometimes submit so best practice is to always say "it's ordinary button, not submit".

    If you need to treat it as block element you can either place it inside containing <div> or manually change its style to display: block;.

    Referring something you said, <input type="button"> is surely not proper in your case, as it's form element and you don't have any form here thus the "pure" button tag is more proper.