basic css issue removing hyperlink underlines - html

Bear with my rudimentary question.
http://jsbin.com/css-play-notfound/6
There is this blue underline thats annoyingly creeping up between my image and Text in the heading.

Two things you can do:
Change this code:
<img src="logo.png" alt="REUNIFY" height="35" />
to this:
<img src="logo.png" alt="REUNIFY" height="35" border="0" />
Also add this to your CSS stylesheet:
a { text-decoration:none }
Note that the above CSS will get rid of the underline on ALL links. So if you want your normal
text links to have the underline and just want this particular link to NOT have the underline,
then create a class like so:
a.noline { text-decoration:none }
and then change your HTML code to this:
<h1><span><a href="http://www.wikipedia.org" class="noline">
<img src="logo.png" alt="REUNIFY" height="35" border="0" />
</a></span>
Welcome
</h1>

Just add the css rule...
text-decoration: none;
... to your <a> element, or to one specific element by using a class or ID.
You can apply it to all hyperlinks like so:
a
{
text-decoration: none;
}

You should always add HTML5 and older browser CSS resets.
http://cssreset.com/ has the most popular ones of 2012. This way, you'll always be starting on a clean slate.

a
{
text-decoration: none;
}
add this in your css

Related

CSS Removing blue outline on HTML email href images

Would like to check what are the approaches that I can use to remove the anonymous blue outline when an email consist of an image href link? I have tried
border: none;
outline: none;
text-shadow: none;
box-shadow: none;
but nothings works.
Remove the border from the image:
a img {
border-style: none;
}
Remove the border by this (if you gave any):
Border:none;
Also try :
<img src="abc.jpg" border="0" />
If there is text decoration then remove it by this:
text-decoration:none;
If there will no changes appear then please you put your code on JSFIDDLE
the problem is not the in a selector but in img selector so you have to remove the border (which is set by default).
since this is for email I would advise you to set border="0" in img, instead CSS above head, just to be more cross-client as possible
something like this:
<img src="img.jpg" alt="img" border="0" />
if you don't like this approach you can always do CSS inline
<img src="img.jpg" alt="img" style="border:0 none" />
See more info about emailing tags/selectors here

Couple of questions HTML

To redefine a general look for an entire HTML tag, what would be the proper selector? Would it be a class, head or id?
Also, not sure which attribute that is used for defining an inline style in HTML? class, font, type, input?
Finally, if I wanted to add a width attribute into a specific item within the html code, would it be: width="10" or width:"10".
Thanks
To redefine a general look for an entire HTML tag, what would be the proper selector? Would it be a class, head or id?
-> To redefine a general look of a tag for the entire page you just need to use the tag name, for example: if you want to change the anchor tag to not have an underline for the entire page you just type this,
a {
text-decoration: none;
}
And if you want to change everything inside a particular tag you could do something like
div * {
padding: auto;
}
Also, not sure which attribute that is used for defining an inline style in HTML? class, font, type, input?
-> As of now it is a good practice not to do inline styling frequently in your code, but if you have to you could style 'almost' all the tags which follow HTML5 syntax. To do that you could write something like this:
<div style="width:200px"><span>Some text here</span></div>
Finally, if I wanted to add a width attribute into a specific item within the html code, would it be: width="10" or width:"10".
-> For styling anywhere and anything you have to use property : value; this syntax, except in javascript. For javascript you have to follow these steps: clickable link
To style an html tag, you just use the tag as a reference:
p {
color: red;
}
h1 {
font-size: 20px;
}
Inline HTML styling is done with the style attribute, but is not recommended.
<h1 style="color:blue">This is a Blue Heading</h1>
To style a tag in general, you wouldn't need to use id, class, or head.
Say you wanted to style all 'p' elements, in CSS you would put:
p {
Property:Value
}
If you wanted to specify an elements width within the HTML code the correct way would be:
width="10" (Within an elements tags of course)
img{
width="100px"
}
.image{
width="100px"
}
#image{
width="100px"
}
<img src="" width="100px" />
<img src=""/>
<img src="" class="image" />
<img id="image" src=""/>
If you wish to define a general look for the whole of the webpage that you wish to create, you can type the body and then define it accordingly.
For example
body{
padding:20px;
color: blue;
}
This will define the styling for all the elements under the body tag.
An alternate way for this is:
*{
padding:20px;
}
By using a Universal selector, you can automatically select all the elements and apply them to the style.
Coming to your last question,
if you are using Inline CSS, you can use both the ways that you have mentioned-
"width=200"and "width:200;"
But if you are directly applying in a tag or under style tag:
<img src="" width=" ">
This is the apt way of doing so.
Thank you
A unique selector is the id.
the class selector is for more than one tag. You use it if you would have that two tags are viewed in the same way. (from your css file)
inline styles:
<p style="border: 1px solid #000000">Hello World</p>
Last que: width="100px" for example:
<img src="pics/pic1.jpg" width="100px" />
The Tag "html" is "only for defining that here starts the document"
You have to style "each" tag (p,div,h1,h2,span,....)
http://de.selfhtml.org/css/

html, displaying a link as normal text

I was wondering if you could display a link as normal text.
<a id="" href="" target="_parent"><img src="" width="121" height="20" alt="">
<div style="position:absolute;left:163px;top:1px;font-size: 12px; display: block">
<font color="white">Log in</font></a>
I'm trying to overlap an image that is also a button, with the text "Log in", it works as it is with the code above, but I was wondering if I can change the "log in" which displays as blue and underlined to appear as normal text.
In css:
a {
color: inherit;
text-decoration: inherit;
}
These values can also be stuck in your anchor tag's style attribute.
Should result in your anchor tags looking the same as the text color and decoration of the parent(s).
If you have a look at Cascading Style Sheets (CSS) you can change the colour and the text style of the link.
In your example, you could use
<a id="" href="" target="_parent" style="color: white; text-decoration: none;"><img src="" width="121" height="20" alt="">
<div style="position:absolute; sleft:163px;top:1px;font-size: 12px; display: block">
<font color="white">Log in</font>
</div>
</a>
However I would learn how to use external stylesheets and link them to your HTML through the <link> tag in the <head> of your html. You can then style up individual tags through the tag name, an id or a css class. So an updated example would be:
<link rel="stylesheet" href="link-to-your-css-file" />
in your css file have
a.imgLink{
color: white; text-decoration: none;
}
div.imgLink{
position: absolute; left: 163px; top: 1px; font-size: 12px; display: block;
}
Then your html would be
<a class="imgLink" id="" href="" target="_parent">
<img src="" width="121" height="20" alt="">
<div class="imgLink">
Log In
</div>
</a>
Not only does it make your HTML "dry" but it gives you greater control over the styles of your html by only changing the css file.
If you don't want the link to be underlined,
set " text-decoration:none"
use this code in your html file
<style>
a {
text-decoration: none;
color: #000; /* or whatever colour your text is */
}
</style>
Short answer: yes.
Longer answer:
Yes, here is a fiddle, but you probably don't want to hide links from your user.
stslavik makes a good point with "text-decoration: inherit". Here is another fiddle. On my browser the "blam" and "stslavic" both show with strike-through, but I'd go with the "inherit" versus the "none"; just seems better to me.
(P.S not advertising this and no spam. Click on 'Hate AI' to reach my project)
You can do this =>
<h1><a style="text-decoration: none; color: inherit;" href="https://obnoxiousnerd.github.io/hate-ai">Hate AI</a></h1>
<p>A personal assistant that hates you but still helps you.</p>
The logic here was adding a style to the a tag which contains the following:-
text-decoration: none;
color: inherit;
text-decoration for removing the underline under the text.
color: inherit for removing the usual purple color of links.
Sure - just adjust the CSS for 'a' elements on the page.
Just a simple snippit to show some size/coloring possibilities, to make your link fit thematically when the rest of your text a bit better.
Wow, Look at this website! It's called Website! It's a shame that this link looks horrible, though!
<h2><a style="color: #A52A2A;; text-decoration: none;" href="https://www.website.com/">Oh, boy! You can now click here to visit Website's website without the link looking bad!</a></h2>
<h2><a style="color: #A52A2A;; text-decoration: none;" href="https://www.bing.com/">Uh oh, the Website website is broken! Visit the pinnacle of innovation, Bing, instead!</a></h2>

Applying Style to Parent By Selecting Child

It appears some browsers (Chrome at least) put a partial underline under images that are nested inside of an anchor tag, like this:
<img src="/foo.jpg" />
So I'm looking for a way to add text-decoration: none; to any anchor tags that contain an img tag. My first thought was this:
a img {
text-decoration: none;
}
Of course that doesn't work, because the style gets applied to the img tag, and not the anchor. So is there a selector I can use to apply the text-decoration style to any anchor tag with a img child?
EDIT:
My HTML typically looks like this:
<a href="#">
<img src="/foo.jpg" />
</a>
The way I space and tab the elements is adding extra whitespace between the anchor tag, and image tag. It's that white space that's being underlined.
If you're against adding a class to this <a> tag (which is the simple solution), your next best CSS solution would be to remove text-decoration on the <a> tag, and wrap the text you want to have underlined in an inline element. See below:
For images:
<a href="#">
<img src="/foo.jpg" alt="etc" />
</a>
For text:
<a href="#">
<span>Text that you probably want underlined</span>
</a>
Combined:
<a href="#">
<img src="/foo.jpg" alt="etc" /> <span>Text that you probably want underlined</span>
</a>
CSS:
a { text-decoration: none; }
a:hover span { text-decoration: underline; }
Unfortunately there is no way currently of selecting the parent of an element using just CSS.
You would need to resort to javascript or jQuery.
Personally I would do something in jQuery like
$('a>img').parent().addClass('noTextDecoration');
then in css have the following:
a.noTextDecoration {test-decoration:none;}
I just use
img {
border:none;
}
So far as I can tell, there is no way to select an element's parent in CSS. You could try applying some class, i.e. imagelink to A elements that contain IMG elements, though.
If the href attribute of these anchors always points to images, and no anchors point to images besides the one with actually an img tag inside, then you can use:
a[href$=".gif"],
a[href$=".png"],
... ,
a[href$=".jpg"] {
text-decoration: none;
}

Remove line under image in link

I have a few instances where I place image within a link. Normally if you set border="0" there line under a link does not apply to the image. However, I had to specify DOCTYPE to be and now in FF I see the line under all images.
I still would like to have my links underlined, but not the images within.
<img src="img.png" height="16" width="16" border="0"> link
I've tried to solve it with CSS by adding
a img {
text-decoration:none
}
Unfortunately it did not work. I also tried:
a img {
border:0
}
IE does not "underline" my images within a link... Any suggestions would be highly appreciated.
Example Link
I still would like to have my links underlined, but not the images within.
If you want to have a special case for links with images, give the a element a class and remove the text-decoration for that class:
HTML:
<img height="16" width="16" />
CSS:
a img
{
border: 0 none;
}
.image-link
{
text-decoration: none;
}
This is great if you only have an image within the link, however you have both text and images within the anchor.
The solution for that would be to add a span around the text within the anchor:
<img height="16" width="16" /> <span>link text here</span>
and add an additional style in the stylesheet:
.image-link span
{
text-decoration: underline;
}
A solution would be to use the image as a background image instead of in the html, possibly the background of the parent element of the a.
In case anyone cares, here's an alternative solution that I came up with to circumvent the issue:
.nl {
text-decoration:none;
}
<img src="img.png" height="16" width="16" border="0"><u>link</u>
a { text-decoration: none }
The underline is from the A-tag not the IMG
For those cases where editing the markup isn't an option (inaccessibility to templates and/or surrounding issues), you can use a little jQuery. You may need to adjust the syntax to override your CSS:
jQuery('a > img').parent().css({'text-decoration' : 'none'});
Solved
<img src="img.png" height="16" width="16" border="0"> link
If you are linking to an image, try the following:
a[href$=jpg], a[href$=png] {
text-decoration: none;
}
My two cents:
$('a').each(function(){
var images = $(this).find("img");
images.parent().addClass('no_border_img');
});
Loop all links and find images inside, then for each one add CSS style to the link.
Only for a image with link inside a previous link style. Remember to create the style for 'no_border_image'.