Sorry if this question might annoy some of you, but please bear in mind that I’m relatively new to web design and coding, I have just finished HTML and CSS and now I’m trying to adapt to it.
Basically the problem goes like this, I want my “p” element to be at the center of a container div, like this.
div
{
width:300px;
height:100px;
}
p
{
position:absolute;
top:auto;
}
</style>
</head>
<body>
<div><p>I want this paragraph to be at the center, but I can't.</p></div>
If anybody could help me on this, I would be really grateful, thanks.
If you meant, you just wanted a paragraph to centre horizontally rather than vertically? All you need have done was: p { text-align: center; } for the paragraph. Though if you meant vertical alignment too - which I suspect - or something other please elaborate more on what you specifically were wanting to achieve. Because if you also added a margin to the P element it could give a basic centred effect.
Hey @juleusjohn ;
We’re running a test of our live CSS problem solving product today.
If you want to utilise our experts to get your site sorted out immediately, you can check it out here http://codefix.sitepoint.com/