Jump to content

Force fonts in html?


Podman
 Share

Recommended Posts

I have a website that all through the site there are a number of different fonts but I want them all to be the same, the site was origionally written with many different editors (although now I modify it with dreamweaver) so the code within it varies. It has a css base file. Is there anyway I can either add code to teh html or even better into the CSS file taht will force it to use one font style even if it sets different ones later in the html? Becuase there are so many different bits of code within teh page, dreamweaver doesn't pick some of it up. (some code says things like font="blah blah" and other uses teh form font:blahblah :).Any help you can give would be much appreciated.Huw.

Link to comment
Share on other sites

I have a website that all through the site there are a number of different fonts but I want them all to be the same, the site was origionally written with many different editors (although now I modify it with dreamweaver) so the code within it varies. It has a css base file. Is there anyway I can either add code to teh html or even better into the CSS file taht will force it to use one font style even if it sets different ones later in the html? Becuase there are so many different bits of code within teh page, dreamweaver doesn't pick some of it up. (some code says things like font="blah blah" and other uses teh form font:blahblah :).Any help you can give would be much appreciated.Huw.
Instead of trying to force a default font over existing code, I'm going to have to suggest that you physically go through your pages and (1) remove all the font declarations embedded in the html that you don't need and to create a new CSS file to deal with those; or (2) change the font declarations in the html code to what you do want. There are a number of ways to efficiently do this, personally I would do global search and replaces using UNIX commands but how you accomplish this task is up to you.It seems like the code you are working with now has been edited in many different ways (by many different people?) and will continue to be edited in such a menner. Trying to force existing code to submit to new code is a really bad way to develop web pages because it creates problems for people like you and me later down the road when we deal with the crap-code.So just take some time to clean up the old code (yes it might be incredibly tedious) but this will save you (and other people) future headaches.Good luck.
Link to comment
Share on other sites

If you really still want to overrule the previous declarations, you can do

* {	font-family:blahblah !important;}

But as they said, it's a bad idea.

Link to comment
Share on other sites

Instead of trying to force a default font over existing code, I'm going to have to suggest that you physically go through your pages and (1) remove all the font declarations embedded in the html that you don't need and to create a new CSS file to deal with those; or (2) change the font declarations in the html code to what you do want. There are a number of ways to efficiently do this, personally I would do global search and replaces using UNIX commands but how you accomplish this task is up to you.It seems like the code you are working with now has been edited in many different ways (by many different people?) and will continue to be edited in such a menner. Trying to force existing code to submit to new code is a really bad way to develop web pages because it creates problems for people like you and me later down the road when we deal with the crap-code.So just take some time to clean up the old code (yes it might be incredibly tedious) but this will save you (and other people) future headaches.Good luck.
If I can help it I would really prefer not too as there are over a 100 pages, and it seems to be stated in there in many different way, it is now only edited by me and using dreamweaver. But the code for each page is soo long it's daft. Kompozer was used a lot and it seems to repeat code like nobodies business. Very untidy.
Link to comment
Share on other sites

If you really still want to overrule the previous declarations, you can do
* {	font-family:blahblah !important;}

But as they said, it's a bad idea.

Would that go in teh css or the html? also does it go at the start or thend?ThanksOh and by teh way teh site is www.redraventherapy.co.uk Thanks again !
Link to comment
Share on other sites

Would that go in teh css or the html? also does it go at the start or thend?
It goes in the CSS - at the end, just in case there is another !important in the stylesheet. But are you sure you really want to proceed?
Link to comment
Share on other sites

It goes in the CSS - at the end, just in case there is another !important in the stylesheet. But are you sure you really want to proceed?
The plan is do the force font as a temp messure, gives me time to work through all the page coding and remove the font statements, can then remove it again from the html then :)Also, may seem a dimb question but I'm assuming I don't put the * at the begiining of the line when I enter code?
Link to comment
Share on other sites

Interesting... it works for me on my test document.That's weird, I can't pick up the rule in my debugger. Umm...Ah, it seems to be the <font> tags that are messing it up. Try removing all those. If DW has Regex replace capacities you can replace

/<font(.*?)>(.*?)</font>/i

with

$2

Link to comment
Share on other sites

Interesting... it works for me on my test document.That's weird, I can't pick up the rule in my debugger. Umm...Ah, it seems to be the <font> tags that are messing it up. Try removing all those. If DW has Regex replace capacities you can replace
/<font(.*?)>(.*?)</font>/i

with

$2

will that get rid of the font size and coloring then? It's only the font face I want to scrap. My dreamweaver uses bbedit to find and replace across multiple files so I think it can do it.
Link to comment
Share on other sites

oh actually I didn't realise my dreamweaver could search across multiple file son it's own, although it doesn't find anything using /<font(.*?)>(.*?)</font>/i as it's search criteria. I'll have a look what teh font commands look like within the html :) Thanks for all your help so far, really is much appreciated.

Link to comment
Share on other sites

oh actually I didn't realise my dreamweaver could search across multiple file son it's own, although it doesn't find anything using /<font(.*?)>(.*?)</font>/i as it's search criteria. I'll have a look what teh font commands look like within the html :) Thanks for all your help so far, really is much appreciated.
In the search box, did you checked "Use regular expression"? It must be for this to work.Place
<font(.*?)>(.*?)</font>

in the "Find" text area. Place

$2

in the "Replace" text area.make sure "Match case" is not checked.Click "Replace All".

Link to comment
Share on other sites

In the search box, did you checked "Use regular expression"? It must be for this to work.Place
<font(.*?)>(.*?)</font>

in the "Find" text area. Place

$2

in the "Replace" text area.make sure "Match case" is not checked.Click "Replace All".

Yes I had use regular expression checked, also had it to check "entire site" and it found nothingthere are a number of font change html codes in eth html though such as "<font color="#336666">" and the other one it uses is "<span class="style1">"I have to be doing something wrong :S
Link to comment
Share on other sites

The classes are fine, because that's CSS. Did the font tags disappear though?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...