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
Use a
div
instead ofp
or use<style>...</style>
at the top of the page if you can and also want to avoid a css fileIf you want to display text without any extra formatting that gets added by
p
tags you can use thespan
tag:span
is an inline element by default. If you want to use a block element, usediv
.More about inline vs block.
Use the
<div>
, or<span>
. The difference is one hasblock
display properties while another hasinline
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.