Jump to content

HTML CSS set variable?

Go to solution Solved by colonel_mortis,

You would need to use a server-side language like PHP to achieve what you want - HTML is a static language (though it can be modified by JS on the client side, but only if the client has JS enabled, which most do but you can't rely on it), and CSS stylesheets can't be modified at all once loaded by the browser (you just have to apply inline styles to modify things using JS).

If you're only using it to make it easier to add super long links, I would recommend just hard coding them (you can always copy and paste), but if you want to get a bit more advanced, a server side language will soon become necessary. PHP is good for the basics, like you want at the moment, but as a language it has a lot of flaws, and I would recommend trying something else like node.js or python's Django framework if you want to do something seriously with web programming (PHP is very widely used (this site runs on PHP), but I wouldn't recommend starting any new projects using it).

Hi, is there a way to predefine something like etc in batch

set link="superlonglink"

 

echo %link%

 

So for the html it would be like this (example on what I'm looking for)

<a href="%link%">here</a>

when visiting the site it would be displayed as <a href="superlonglink">here</a>

Back-end developer, electronics "hacker"

Link to comment
https://linustechtips.com/topic/666265-html-css-set-variable/
Share on other sites

Link to post
Share on other sites

You would need to use a server-side language like PHP to achieve what you want - HTML is a static language (though it can be modified by JS on the client side, but only if the client has JS enabled, which most do but you can't rely on it), and CSS stylesheets can't be modified at all once loaded by the browser (you just have to apply inline styles to modify things using JS).

If you're only using it to make it easier to add super long links, I would recommend just hard coding them (you can always copy and paste), but if you want to get a bit more advanced, a server side language will soon become necessary. PHP is good for the basics, like you want at the moment, but as a language it has a lot of flaws, and I would recommend trying something else like node.js or python's Django framework if you want to do something seriously with web programming (PHP is very widely used (this site runs on PHP), but I wouldn't recommend starting any new projects using it).

HTTP/2 203

Link to comment
https://linustechtips.com/topic/666265-html-css-set-variable/#findComment-8601117
Share on other sites

Link to post
Share on other sites

5 minutes ago, colonel_mortis said:

You would need to use a server-side language like PHP to achieve what you want - HTML is a static language (though it can be modified by JS on the client side, but only if the client has JS enabled, which most do but you can't rely on it), and CSS stylesheets can't be modified at all once loaded by the browser (you just have to apply inline styles to modify things using JS).

If you're only using it to make it easier to add super long links, I would recommend just hard coding them (you can always copy and paste), but if you want to get a bit more advanced, a server side language will soon become necessary. PHP is good for the basics, like you want at the moment, but as a language it has a lot of flaws, and I would recommend trying something else like node.js or python's Django framework if you want to do something seriously with web programming (PHP is very widely used (this site runs on PHP), but I wouldn't recommend starting any new projects using it).

Okey, Yea I ended up with just using local pictures (thats what I where trying to) I just dident realise upper case mattered so when it was looking for the R6-Operator.png it just gave me 404. and I knew it was there so ended up with posting it to imgur and using that link (then wanted to shorten the links and have it all easy to use). And by looking into it I saw that it was saved as R6-operator.png and that solved my problem :P Thanks anyways.

Back-end developer, electronics "hacker"

Link to comment
https://linustechtips.com/topic/666265-html-css-set-variable/#findComment-8601130
Share on other sites

Link to post
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

×