Coding help with font size using Javascript inside this code

Ok, I admit, I don’t use Javascript to code with but I’m trying to help a church with their page. We are using this script to be able to click one item and open two pages at the same time. It works great at doing that. The problem is how do I change the font that is on the page from the link “Click here”. Everything I’ve tried has failed. Right now it comes out exceptionally small.

This is an example of the code I’m using except different pages to open.

 <p>
  <a href="#" onclick="window.open('http://google.com'); window.open('http://yahoo.com');">Click here</a>
</p>

I added a few spaces so the coding would show.

Help please?

Are the links to internal or external pages? Because you can’t control the font size of external pages (Well, you can in each individual browser that visits the page but that is only if the user of the browser does so, that is, change the default font size in the browser)


I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Thanks for explaining using the ticks for the coding. Tried looking and didn’t see a way of doing it. As for the links, they are external. All I’m trying to change is the size of the displayed text for the link. the “Click Here” that is put on the page. That text appears extremely small on the page. I used to do html coding so figured it’s some sort of “font” code but not sure how to add it in javascript.

Welcome to the forums.

As far as I know, there is no font-size attribute for html tags. You’d either have to change the font size on the style sheet itself. Or you’d have to access the style object in the script.js file and change the size there.

Doing it via CSS would definitely be the easier way.

Ah OK I see. You can target the element and set the font size as needed. I would add a class to the element.

HTML

 <p>
  <a class="outbound-link" href="#" onclick="window.open('http://google.com'); window.open('http://yahoo.com');">Click here</a>
</p>

CSS

.outbound-link {
  /* set the size here */
  font-size: 1.6rem;
}

Or using inline styles (style attribute)

HTML

 <p>
  <a style="font-size: 1.6rem;" href="#" onclick="window.open('http://google.com'); window.open('http://yahoo.com');">Click here</a>
</p>
2 Likes

Awesome, the HTML code did what I needed. Now I can lean on some of my old HTML if I can remember it get the attributes where I want. Everything I tried before wouldn’t work. Thank you so much.
So hard working on someone else’s page when they want to use an online resource that controls everything.