Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

HTML 5 and Css

Posted on 2013-02-02
3
Medium Priority
?
175 Views
Last Modified: 2013-02-02
Hello folks,

   I have a page in which I am converting to use HTML 5. As such, I am creating a css for it. The existing web page uses the <div align="center"> and I am stumped as to what the equalivent would be in CSS. It will have an image and I want it to be centered on the page displayed to the viewer.
Your help is appericiated. :)
0
Comment
Question by:Overthere
3 Comments
 
LVL 11

Accepted Solution

by:
MajorBigDeal earned 2000 total points
ID: 38847032
www.w3.org/Style/Examples/007/center.en.html

P.blocktext {
    margin-left: auto;
    margin-right: auto;
    width: 6em
}
0
 
LVL 6

Expert Comment

by:nickinthooz
ID: 38847064
#div {
text-align:center;
padding: 10px;
}

Open in new window


you can do it with other tags but make sure they are the same size as your div in order to find a true center.

For Example:
#mydiv {
width:300px;
height:300px;
text-align: center;
border:dashed;
}
#p {
width: 280px;
padding: 0 10px 0 10px;
}

Open in new window

<div id="mydiv"><p>this is your centered text</p></div>

Open in new window

Here is a jfiddle example of it.
0
 

Author Closing Comment

by:Overthere
ID: 38847442
Thank all of you for responding. The link provided by MajorBigDeal was excellent and very helpful.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question