Assigning multiple styles on an HTML element

I'm just starting out with HTML and I'm having a trouble assigning multiple styles to a text. I'd like to create a title with two properties:

  1. Centered
  2. Font: Tahoma

I have tried this one:

<h2;"font-family:tahoma">TITLE</h2>

but it doesn't work...

What am I doing wrong?

1

4 Answers

In HTML the style attribute has the following syntax:

style="property1:value1;property2:value2"

so in your case:

<h2>TITLE</h2>

Hope this helps.

The syntax you used is problematic. In html, an attribute (ex: style) has a value delimited by double quotes. In that case, the value of the style attribute is a css list of declarations. Try this:

<h2>TITLE</h2>

The way you have used the HTML syntax is problematic.

This is how the syntax should be

style="property1:value1;property2:value2"

In your case, this will be the way to do

<h2 >TITLE</h2>

A further example would be as follows

<div class ="row"> <button type="button" style= "margin-top : 20px; border-radius: 15px">View Full Profile</button>
</div>

I got stuck on the same issue and I hope this helps someone someday:

<style> .red-text { color: red;} p {font-size: 16px;}
</style>
2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like