Set the desired font size to 2 using CSS styling

I need to work with a different company's markup code, and it's quite unconventional. I'm only able to edit the CSS, not the HTML itself. The markup code I have to deal with looks like this:

<p>
  <font size="2">Headline</font>
  <font size"1">Paragraph text</font>
</p>

I want to style the color and other properties of these two elements differently, but I'm unsure how to target them using CSS. Could it be done like this?

font[size=2] {
  color: red;
}

font[size=1] {
  green;
}

Answer №1

font[size="2"] {
  color: blue;
}

font[size="1"] {
  color: yellow;
}
<p>
  <font size="2">Title</font>
  <font size="1">Body text</font>
</p>

Answer №2

When using attribute and value selector, the value must be within quotation marks like font[size="1"]

font[size="2"] {
  color: red;
}

font[size="1"] {
  color: green;
}
<p>
  <font size="2">Headline</font>
  <font size="1">Paragraph text</font>
</p>

Answer №3

The font[size=1] was employed, however enclosed in quotation marks as seen here: font[size="1"]

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Modifying properties through JavaScript is not possible

I created an HTML form and I'm trying to change the attributes of a div and a button but for some reason, it's not working <form> <button type='button' id='other'>Sub</button> <select id="prop"> &l ...

Spinning Earth orbits around the Sun

My goal is to create a 3D Solar system, starting with the Sun and Earth using THREE.SphereGeometry() var sphere2 = new THREE.Mesh(new THREE.SphereGeometry(50, 100, 100), new THREE.MeshBasicMaterial({side: THREE.DoubleSide, map:txt2})); sphere2.position.se ...

Deactivate input fields when the checkbox is selected

In my ticket purchase form, you are required to fill in all personal information. However, there is an option to purchase an empty ticket without any name on it. This can be done by simply checking a checkbox, which will then disable all input fields. ...

Aligning text of different sizes vertically in CSS

Struggling with a text line that contains multiple font sizes? Want all the text to align with the middle of the .line1 element? I tried using vertical-align:middle, but it's not working as expected. Check out the code on JSfiddle: http://jsfiddle.net ...

Steps to align div directly to the left of the button that was clicked

I have a div in my code that is hidden by default. I want to show this div exactly left whenever the user clicks on the show button. Since there are multiple show buttons on my page, I would like to display the div as described above. <div id="me ...

Internet Explorer is not recognizing the max-width property as expected

Every time I adjust the max-width setting, I see no difference. It was working fine before, but now it's not changing anything. I must be missing something simple or maybe a semicolon somewhere. CSS isn't my strong suit, but I'm trying to le ...

The GIF Loader fails to animate while an AJAX request is in progress

Displaying a DIV element containing a loading GIF image while waiting for an AJAX call response. Initially, the DIV element is hidden. Upon clicking a checkbox, the loader DIV is shown, followed by the completion of the AJAX call, and then hiding the load ...

Center inline-block elements inside a container with vertical alignment and justification

Although this question has been raised multiple times, I have not been able to find a solution tailored to my specific situation. Here is an example of what I am dealing with: DEMO Essentially, it involves a list of rows: <ul> <li> ...

Display the button only if the specified condition aligns with the input data

I am working on a project where I have an input text field that retrieves data from a database using a combination of JavaScript and PHP. get.html is responsible for fetching the data through JavaScript. function showUser(str) { if (str == "") { ...

Tips for minimizing padding and margin in a Bootstrap template

I recently downloaded the page from "https://getbootstrap.com/docs/5.3/examples/heroes/", and I've removed all sections in index.html except for the "hero" section and the "sign-up form". However, there is too much white space between these two elemen ...

What is the best way to ensure that a div within a flexbox column item is 100% in

I am struggling to make a div inside a flex box item take up 100% height. Here is the current setup: #outer (display: fled, flex-direction: column, height: 100px) #header (height: auto) #middle (flex-grow: 1) #inner (height: 100%) The goal is for ...

"Creating a fixed header with jQuery by manipulating the offset and scrollTop

My goal is to create a smooth scrolling website that scrolls vertically using jQuery. I found a helpful tutorial called Smooth Scrolling Website and have been following it closely to build my site. However, I'm facing an issue with a fixed header - t ...

What is the best way to center a navbar vertically inside a div?

I've come across some posts mentioning the need for a container with h-100 to align items using the align-self class. However, I'm facing issues aligning a navbar at the bottom of a div. When I place the navbar within another container and row, i ...

Tips for utilizing the two-function in jQuery to showcase one DIV following another DIVNote: When using the two-function

Apologies in advance for my poor English skills, but I have been contemplating whether to write here and if you will be able to understand me. I am currently working on a jQuery script: $(function() { $('#div1').hover(function() { $ ...

"Slice" the text in HTML

In my HTML code, I utilize a smarty variable; <div class="ty-blog__date">{$subpage.timestamp|date_format:"`$settings.Appearance.date_format`"}</div> {$subpage.timestamp|date_format:"$settings.Appearance.date_format"} When compiled, the dat ...

Is it possible to target elements within a UMAP iframe using CSS?

I have integrated a uMap map into my website. Here is the code: <iframe id="umapiframe" class="iframe-umap" width="100%" height="300px" frameborder="0" allowfullscreen src="//umap.openstreetmap.fr/f ...

Unable to alter background color of checkbox with jQuery slide toggle

I've been working on changing the background colour of the toggle button to green when it's turned on. I feel like I've followed all the correct steps, but for some reason, the background just stays grey. Can anyone point out what might be ...

Customize button appearance within mat-menu in Angular versions 2 and above

Is there a way to style my mat-menu to function similar to a modal dialog? I am having difficulty with the styling aspect and need advice on how to move the save and reset buttons to the right while creating space between them. I have attempted to apply st ...

Jquery oscillation effect

I am attempting to create a seesaw effect using jQuery, but I'm unsure about which plugin would be best for this task. The goal is to have the bar move up and down while the box on top moves in sync with it. You can find my code on JsFiddler here: htt ...

Tips for updating the class of a button upon clicking it

I have a dilemma with my two buttons - one is green and the other has no background. I want them to change appearance when clicked, from green to one with a dashed border-bottom style. Below is the HTML code for these buttons: <div class="btns"> ...