skip to Main Content

How can I ensure that I don’t have to use p tags for HTML styling? Currently, I am using <p style="xyz">ExampleName</p>, but it seems to be disrupting the entire layout. How can I optimize this, preferably without or with minimal use of CSS?

With the usage of p-tags my whole signature creates paragraphs that I don’t want.
I pretty much want the same outcome as if I would use the p-Tags.

(<p style="xyz">ExampleName</p>)

3

Answers


  1. Use a div instead of p or use <style>...</style> at the top of the page if you can and also want to avoid a css file

    Login or Signup to reply.
  2. If you want to display text without any extra formatting that gets added by p tags you can use the span tag:

    <span style="xyz">ExampleName</span>
    

    span is an inline element by default. If you want to use a block element, use div.
    More about inline vs block.

    Login or Signup to reply.
  3. Use the <div>, or <span>. The difference is one has block display properties while another has inline display properties respectively.

    Another alternative approach is to use reset.css which eliminates <p> tag’s default margin across all browsers. I still would recommend using <p> tag if you are concerned about SEO.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search