-1

So, I have this code

<div id="timer"> </div> 

How can I centrate this in HTML5? I tried but as far I as know, it's obsolete for HTML5 and I must use CSS Any help?

2
  • please provide some code Commented Apr 2, 2019 at 12:30
  • @Error70 Yeah, sorry. Now it should appear in the question Commented Apr 2, 2019 at 12:34

2 Answers 2

1

You can't (or, more specifically, shouldn't) do any kind of styling in HTML, that's what the CSS exists for.

The text-align property could be a beginning.

Here is a great source of information : https://www.w3schools.com/css/

Sign up to request clarification or add additional context in comments.

1 Comment

Oh Matte', io ti ho solo chiesto come faccio a centrare quel porc'iddio di codice, non lezioni sul css :-)
1

You can achieve this by using Flexbox. Try below code snippet it'll help you out. Thanks

#parent {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
}
<div id="parent">
  <div id="timer">Timer</div> 
</div>

4 Comments

Do I must insert the #parent code into <style>?
Yes, you have to add #parent CSS, because flexbox CSS apply on the parent container. Thanks
Still not working... A thing I didn't said, its that the text (timer) i want to align to the center, it's a countdown from 60 to 0 Maybe that's the problem
can you share the link? Thanks

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.