Search code examples
htmlcssaliasheadsimplify

How can I simplify code in the body by working through the head?


New to this, bare with me please.

I've started having fun with HTML code doing offline documents. I just found out that I could easily change my font, in the head, by adding this:

<style type=text/css>
    mkf { font-family:'Courier'; color:red; }
</style>

Then, as I go to add code to , every time I want to change the font of a select group of word with the addition of the color red, I just need to type

<mkf>words here</mkf>

Wonderful! It saves me so much time. But then I got to wonder, what if I wanted to add a link to a word. For example, instead of typing all of this out:

<a href="to_do_list.pdf"><mkf>Example1</mkf></a>

I would simply be able to parse whatever text I inputted between, let's say,

<linkandfont>Example1</linkandfont>,

which would basically create a link to the file "to_do_list.pdf".

I've tried to find a name or term for this so that I can study and learn more, but I have not found it yet.

Thank you.


Solution

  • You cannot. Only way to create a link in HTML is by typing <a href="URL">description</a>. You could also shorten by using JavaScript but that's not HTML.

    The way you changed the color in head is part of styling or CSS, so you could give a class to a tag like <a class='redlink' href='.. and define that class in head like you did with mkf : .redlink {color:red} or if you want all your links to be red then you could give color to a in head style: a {color:red;}

    By typing <mkf> in body I guess you created custom tag which is not part of standard HTML tags, more proper way would be using class to a standard tag like div or p.