seting a title, font size and color same time
guys I started coding html just 1 hour ago (I’m a high school student and I know nothing) and I’m looking for seting a title, font size and color but same time. I looked up everywhere for solution but I couldn’t find it. Can you help me that’s what I use for format
You have serious errors in your code:
<h1 font size = "5" color ="#ff1794" > title="That's the title"> Title </font></h1>
Here’s an analysis of each of the errors. You should check the MDN (Mozilla Developer Network) links for more information:
- HTML Attributes are always one word.
font size
will not work (and it doesn’t exist anyway). What’s more, font size needs to be defined with units, e.g.px
. - You have closed the
<h1>
tag and then add another attribute:> title ... >
- You have a closing
</font>
tag but never had an opening one.
I’ve rewritten the entire code snippet into something with no typos and is much more correct by convention. Now it’s your turn to see what you can learn from this. Notice that I’ve put the CSS separate from the HTML. That’s because stylesheets (presentation) and markup (structure) should be kept separate.
h1 { font-size: 50px; color: #ff1794; }
<h1 title="That's the title">Title</h1>
Or, if you just want to paste the HTML to your webpage, including all meta
:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>My First Webpage</title> <style> h1 { font-size: 50px; color: #ff1794; } </style> </head> <body> <h1 title="That's the title">Title</h1> </body> </html>
I took a look at your code, and there are some things wrong in your syntax. Your code:
<h1 font size = "5" color = #ff1794 > title="That's the title"> Title </font></h1>
The right way to do this, nowadays, is using CSS, because the tag font is not supported in HTML5. (https://www.w3schools.com/tags/tag_font.asp).
You can do something like this:
<h1 style="font-size:26px; color:#ff1794">That's the title</h1>
As you mentioned you’re a high-school student and still do not know with HTML, I suggest you some online courses, if you google "HTML & CSS online courses" you’ll get a lot of good suggestions and, certainly, in a couple of weeks you’ll acquire a nice knowledge 🙂
Put this in your document <head>
:
<title>My Title</title>
This will set the title of your website.
To change the font size of an element, add this HTML attribute:
style="font-size: 4.4rem; color: green"
Keep in mind that the style
attribute is for CSS, and color
defines the text color. You can set the color as any value from red to black and if you want a custom color, search for a color picker, select a color and take the hex code. It will start with a #
, when copying the hex you MUST include the #
otherwise it will not work.